1 | /**
|
2 | * Defines the base Nest HTTP exception, which is handled by the default
|
3 | * Exceptions Handler.
|
4 | *
|
5 | * @see [Built-in HTTP exceptions](https://docs.nestjs.com/exception-filters#built-in-http-exceptions)
|
6 | *
|
7 | * @publicApi
|
8 | */
|
9 | export declare class HttpException extends Error {
|
10 | private readonly response;
|
11 | private readonly status;
|
12 | /**
|
13 | * Instantiate a plain HTTP Exception.
|
14 | *
|
15 | * @example
|
16 | * `throw new HttpException()`
|
17 | *
|
18 | * @usageNotes
|
19 | * The constructor arguments define the response and the HTTP response status code.
|
20 | * - The `response` argument (required) defines the JSON response body.
|
21 | * - The `status` argument (required) defines the HTTP Status Code.
|
22 | *
|
23 | * By default, the JSON response body contains two properties:
|
24 | * - `statusCode`: the Http Status Code.
|
25 | * - `message`: a short description of the HTTP error by default; override this
|
26 | * by supplying a string in the `response` parameter.
|
27 | *
|
28 | * To override the entire JSON response body, pass an object to the `createBody`
|
29 | * method. Nest will serialize the object and return it as the JSON response body.
|
30 | *
|
31 | * The `status` argument is required, and should be a valid HTTP status code.
|
32 | * Best practice is to use the `HttpStatus` enum imported from `nestjs/common`.
|
33 | *
|
34 | * @param response string or object describing the error condition.
|
35 | * @param status HTTP response status code.
|
36 | */
|
37 | constructor(response: string | Record<string, any>, status: number);
|
38 | initMessage(): void;
|
39 | initName(): void;
|
40 | getResponse(): string | object;
|
41 | getStatus(): number;
|
42 | static createBody(objectOrError: object | string, description?: string, statusCode?: number): object;
|
43 | }
|