new HttpException(response: string | Record<string, any>, status: number): HttpException
Instantiate a plain HTTP Exception.
example
throw new HttpException()
usagenotes
The constructor arguments define the response and the HTTP response status code.
The response argument (required) defines the JSON response body.
The status argument (required) defines the HTTP Status Code.
By default, the JSON response body contains two properties:
statusCode: the Http Status Code.
message: a short description of the HTTP error by default; override this
by supplying a string in the response parameter.
To override the entire JSON response body, pass an object to the createBody
method. Nest will serialize the object and return it as the JSON response body.
The status argument is required, and should be a valid HTTP status code.
Best practice is to use the HttpStatus enum imported from nestjs/common.
Defines the base Nest HTTP exception, which is handled by the default Exceptions Handler.
Base Exceptions