allow stack traces in the browser
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user