wishthis/node_modules/es5-ext/error/custom.js

21 lines
590 B
JavaScript
Raw Normal View History

2022-01-21 08:28:41 +00:00
"use strict";
var assign = require("../object/assign")
, isObject = require("../object/is-object")
, isValue = require("../object/is-value")
, captureStackTrace = Error.captureStackTrace;
2022-03-14 15:40:45 +00:00
module.exports = function (message /*, code, ext*/) {
2022-01-21 08:28:41 +00:00
var err = new Error(message), code = arguments[1], ext = arguments[2];
if (!isValue(ext)) {
if (isObject(code)) {
ext = code;
code = null;
}
}
if (isValue(ext)) assign(err, ext);
if (isValue(code)) err.code = code;
if (captureStackTrace) captureStackTrace(err, module.exports);
return err;
};