File

src/module/routing/exception/api.exception.ts

Extends

HttpException

Index

Properties
Methods

Constructor

constructor(data?: any)
Parameters :
Name Type Optional
data any Yes

Properties

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'

Methods

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

		}

	}

}

result-matching ""

    No results matching ""