Custom JavaScript error class code

From , 5 Years ago, written in JavaScript, viewed 249 times.
URL https://pastebin.vip/view/aef546f2
  1. var http = require('http');
  2.  
  3. // Http错误
  4. function HttpError(code, msg) {
  5.     Error.captureStackTrace(this, arguments.callee);
  6.     this.name = arguments.callee.name;
  7.  
  8.     var status = http.STATUS_CODES;
  9.  
  10.     if (!code || !(code in status))
  11.         code = 500;
  12.  
  13.     if (!msg)
  14.         msg = status[code];
  15.  
  16.     this.message = msg;
  17.     this.code = code;
  18. }
  19.  
  20. HttpError.prototype = Object.create(Error.prototype);
  21. //javascript/8224

Reply to "Custom JavaScript error class code"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website