mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2025-01-01 03:31:21 +00:00
23 lines
397 B
JavaScript
23 lines
397 B
JavaScript
'use strict';
|
|
|
|
function createError(msg, code, props) {
|
|
var err = msg instanceof Error ? msg : new Error(msg);
|
|
var key;
|
|
|
|
if (typeof code === 'object') {
|
|
props = code;
|
|
} else if (code != null) {
|
|
err.code = code;
|
|
}
|
|
|
|
if (props) {
|
|
for (key in props) {
|
|
err[key] = props[key];
|
|
}
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
module.exports = createError;
|