Merge pull request #152 from strongloop/fix-validation-error-stack-in-browsers
[2.0] validations: support non-V8 browsers
This commit is contained in:
commit
89fbf168fc
|
@ -703,11 +703,21 @@ function ValidationError(obj) {
|
||||||
messages: obj.errors
|
messages: obj.errors
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (Error.captureStackTrace) {
|
||||||
|
// V8 (Chrome, Opera, Node)
|
||||||
Error.captureStackTrace(this, this.constructor);
|
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);
|
util.inherits(ValidationError, Error);
|
||||||
|
|
||||||
|
var errorHasStackProperty = !!(new Error).stack;
|
||||||
|
|
||||||
function formatErrors(errors) {
|
function formatErrors(errors) {
|
||||||
var DELIM = '; ';
|
var DELIM = '; ';
|
||||||
errors = errors || {};
|
errors = errors || {};
|
||||||
|
|
Loading…
Reference in New Issue