src/module/routing/exception/invalid.params.exception.ts
Properties |
Methods |
constructor(errors: ValidationError[])
|
||||||
Parameters :
|
code |
Type : number
|
Default value : 10
|
http_status_code |
Default value : HttpStatus.BAD_REQUEST
|
message |
Type : string
|
Default value : 'Invalid Params'
|
code |
Type : number
|
Default value : 1
|
Inherited from
ApiException
|
Defined in
ApiException:5
|
data |
Default value : undefined
|
Inherited from
ApiException
|
Defined in
ApiException:8
|
http_status_code |
Default value : HttpStatus.INTERNAL_SERVER_ERROR
|
Inherited from
ApiException
|
Defined in
ApiException:7
|
message |
Type : string
|
Default value : 'Internal Server Error'
|
Inherited from
ApiException
|
Defined in
ApiException:6
|
toJSON |
toJSON()
|
Inherited from
ApiException
|
Defined in
ApiException:21
|
Returns :
{ code: number; message: string; data: any; } | { code: number; message: string; data?: undefined...
|
import { ApiException } from './api.exception';
import { HttpStatus } from '@nestjs/common';
import { ValidationError } from 'class-validator';
export class InvalidParamsException extends ApiException {
code = 10;
message = 'Invalid Params';
http_status_code = HttpStatus.BAD_REQUEST;
constructor(errors: ValidationError[]) {
super();
const validationErrors = [];
errors.forEach(message => {
const messages = [];
for(let prop in message.constraints){
messages.push(message.constraints[prop]);
}
validationErrors.push({
field: message.property,
errors: messages
});
})
this.data = validationErrors;
}
}