Skip to content
Permalink
Browse files

fix: instanceof JoiValidationError

  • Loading branch information...
kirillgroshkov committed Feb 23, 2019
1 parent 6a8ecbf commit f6be36efc689b931b2f2c8b7e0c56a5af82b79d2
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/validation/joi/joi.validation.error.ts
@@ -9,5 +9,20 @@ export interface JoiValidationErrorData extends ErrorData {
export class JoiValidationError extends AppError<JoiValidationErrorData> {
constructor (message: string, data: JoiValidationErrorData) {
super(message, data)

this.constructor = JoiValidationError
;(this as any).__proto__ = JoiValidationError.prototype
Object.defineProperty(this, 'name', {
value: this.constructor.name,
configurable: true,
})

if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor)
} else {
Object.defineProperty(this, 'stack', {
value: new Error().stack,
})
}
}
}

0 comments on commit f6be36e

Please sign in to comment.
You can’t perform that action at this time.