validations: support non-V8 browsers
Call `Error.captureStackTrace()` only when it is available. Use `this.stack = (new Error).stack` when `captureStackTrace` is not available but the `stack` property is (Firefox).
This commit is contained in:
parent
ce8254125f
commit
3572ecd12d
|
@ -703,11 +703,21 @@ function ValidationError(obj) {
|
|||
messages: obj.errors
|
||||
};
|
||||
|
||||
if (Error.captureStackTrace) {
|
||||
// V8 (Chrome, Opera, Node)
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
} else if (errorHasStackProperty) {
|
||||
// Firefox
|
||||
this.stack = (new Error).stack;
|
||||
}
|
||||
// Safari and PhantomJS initializes `error.stack` on throw
|
||||
// Internet Explorer does not support `error.stack`
|
||||
}
|
||||
|
||||
util.inherits(ValidationError, Error);
|
||||
|
||||
var errorHasStackProperty = !!(new Error).stack;
|
||||
|
||||
function formatErrors(errors) {
|
||||
var DELIM = '; ';
|
||||
errors = errors || {};
|
||||
|
|
Loading…
Reference in New Issue