JAVASCRIPT   16

custom js

Guest on 16th July 2022 03:43:35 PM

  1. "use strict";
  2.  
  3. var assign            = require("../object/assign")
  4.   , isObject          = require("../object/is-object")
  5.   , isValue           = require("../object/is-value")
  6.   , captureStackTrace = Error.captureStackTrace;
  7.  
  8. exports = module.exports = function (message /*, code, ext*/) {
  9.         var err = new Error(message), code = arguments[1], ext = arguments[2];
  10.         if (!isValue(ext)) {
  11.                 if (isObject(code)) {
  12.                         ext = code;
  13.                         code = null;
  14.                 }
  15.         }
  16.         if (isValue(ext)) assign(err, ext);
  17.         if (isValue(code)) err.code = code;
  18.         if (captureStackTrace) captureStackTrace(err, exports);
  19.         return err;
  20. };

Raw Paste


Login or Register to edit or fork this paste. It's free.