1
0

custom.js 522 B

1234567891011121314151617181920
  1. 'use strict';
  2. var assign = require('../object/assign')
  3. , captureStackTrace = Error.captureStackTrace;
  4. exports = module.exports = function (message/*, code, ext*/) {
  5. var err = new Error(), code = arguments[1], ext = arguments[2];
  6. if (ext == null) {
  7. if (code && (typeof code === 'object')) {
  8. ext = code;
  9. code = null;
  10. }
  11. }
  12. if (ext != null) assign(err, ext);
  13. err.message = String(message);
  14. if (code != null) err.code = String(code);
  15. if (captureStackTrace) captureStackTrace(err, exports);
  16. return err;
  17. };