Skip to content

Commit

Permalink
fix: exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Zakharov committed May 14, 2022
1 parent 7fb0ab3 commit c3f263a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/exception.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { BadRequestException } from '@nestjs/common'
import { ZodError, ZodIssue } from 'zod'
import { BadRequestException, HttpStatus } from '@nestjs/common'
import { ZodError } from 'zod'

export class ZodValidationException extends BadRequestException {
errors: ZodIssue[]

constructor(private error: ZodError) {
super('Validation failed')
this.errors = error.errors
super({
statusCode: HttpStatus.BAD_REQUEST,
message: 'Validation failed',
errors: error.errors,
})
}

public getZodError() {
Expand Down

0 comments on commit c3f263a

Please sign in to comment.