自定义JavaScript Error类代码,有了这段代码就可以自定义js代码处理的方式
var http = require('http');
// Http错误
function HttpError(code, msg) {
Error.captureStackTrace(this, arguments.callee);
this.name = arguments.callee.name;
var status = http.STATUS_CODES;
if (!code || !(code in status))
code = 500;
if (!msg)
msg = status[code];
this.message = msg;
this.code = code;
}
HttpError.prototype = Object.create(Error.prototype);
