Skip to content

Commit fd06ed2

Browse files
committed
Sen original error in EntityError instance when availbale
1 parent ff1d282 commit fd06ed2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/entity-error.js

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ function EntityError(options) {
1010
if (options.type) {
1111
this.type = options.type
1212
}
13+
if (options.err) {
14+
this.originalError = options.err
15+
}
1316
}
1417
EntityError.prototype = Object.create(Error.prototype)
1518
EntityError.prototype.constructor = EntityError

src/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -756,14 +756,16 @@ function runHooks(hooks, model, options, data, validatedInstance) {
756756
throw new EntityError({
757757
type: hook.name + 'HookError',
758758
message: err.message,
759-
errors: [{path: hook.id, message: err.message}]
759+
errors: [{path: hook.id, message: err.message}],
760+
err
760761
})
761762
}
762763
if (res && res.then) {
763764
return res.catch(function(err) {
764765
throw new EntityError({
765766
message: hook.name + ' hook error',
766-
errors: [{path: hook.id, message: err.message}]
767+
errors: [{path: hook.id, message: err.message}],
768+
err
767769
})
768770
})
769771
}

0 commit comments

Comments
 (0)