Skip to content

Commit

Permalink
fix: instanceof JoiValidationError
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Feb 23, 2019
1 parent 6a8ecbf commit f6be36e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/validation/joi/joi.validation.error.ts
Expand Up @@ -9,5 +9,20 @@ export interface JoiValidationErrorData extends ErrorData {
export class JoiValidationError extends AppError<JoiValidationErrorData> { export class JoiValidationError extends AppError<JoiValidationErrorData> {
constructor (message: string, data: JoiValidationErrorData) { constructor (message: string, data: JoiValidationErrorData) {
super(message, data) 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.