src/module/routing/exception/api.exception.ts
HttpException
Properties |
Methods |
constructor(data?: any)
|
||||||
Parameters :
|
code |
Type : number
|
Default value : 1
|
data |
Default value : undefined
|
http_status_code |
Default value : HttpStatus.INTERNAL_SERVER_ERROR
|
message |
Type : string
|
Default value : 'Internal Server Error'
|
toJSON |
toJSON()
|
Returns :
{ code: number; message: string; data: any; } | { code: number; message: string; data?: undefined...
|
import { HttpException, HttpStatus } from '@nestjs/common'
export class ApiException extends HttpException {
code = 1
message = 'Internal Server Error'
http_status_code = HttpStatus.INTERNAL_SERVER_ERROR
data = undefined
constructor(data?: any) {
super({
code: 1,
message: 'Internal Server Error'
}, HttpStatus.INTERNAL_SERVER_ERROR)
this.data = data
}
toJSON() {
if(this.data !== undefined){
return {
code: this.code,
message: this.message,
data: this.data
}
}
return {
code: this.code,
message: this.message
}
}
}