allow stack traces in the browser

This commit is contained in:
Spencer Alger
2014-05-02 09:26:31 -07:00
parent 6ca4fca6cc
commit 611be9d616

View File

@ -1,15 +1,23 @@
var _ = require('./utils');
var errors = module.exports;
var canCapture = (typeof Error.captureStackTrace === 'function');
var canStack = !!(new Error()).stack;
function ErrorAbstract(msg, constructor) {
this.message = msg;
Error.call(this, this.message);
if (process.browser) {
this.stack = '';
} else {
if (canCapture) {
Error.captureStackTrace(this, constructor);
}
else if (canStack) {
this.stack = (new Error()).stack;
}
else {
this.stack = '';
}
}
errors._Abstract = ErrorAbstract;
_.inherits(ErrorAbstract, Error);