HttpException
Defines the base Nest HTTP exception, which is handled by the default Exceptions Handler.
class HttpException extends IntrinsicException {
static createBody<Body extends Record<string, unknown>>(arg0: HttpExceptionBodyMessage | Body, arg1?: HttpExceptionBodyMessage, statusCode?: number): HttpExceptionBody | Body
static getDescriptionFrom(descriptionOrOptions: string | HttpExceptionOptions): string
static getHttpExceptionOptionsFrom(descriptionOrOptions: string | HttpExceptionOptions): HttpExceptionOptions
static extractDescriptionAndOptionsFrom(descriptionOrOptions: string | HttpExceptionOptions): DescriptionAndOptions
constructor(response: string | Record<string, any>, status: number, options?: HttpExceptionOptions)
cause: unknown
initCause(): void
initMessage()
initName(): void
getResponse(): string | object
getStatus(): number
// inherited from nest/packages/common/IntrinsicException
}
Subclasses
-
BadGatewayException
-
BadRequestException
-
ConflictException
-
ForbiddenException
-
GatewayTimeoutException
-
GoneException
-
HttpVersionNotSupportedException
-
ImATeapotException
-
InternalServerErrorException
-
MethodNotAllowedException
-
MisdirectedException
-
NotAcceptableException
-
NotFoundException
-
NotImplementedException
-
PayloadTooLargeException
-
PreconditionFailedException
-
RequestTimeoutException
-
ServiceUnavailableException
-
UnauthorizedException
-
UnprocessableEntityException
-
UnsupportedMediaTypeException
See also
Static methods
createBody() | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3 overloads...Show All Hide All expand_moreOverload #1
Parameters
ReturnsOverload #2
Parameters
ReturnsOverload #3 |
getDescriptionFrom() | ||||||
---|---|---|---|---|---|---|
Parameters
Returns |
getHttpExceptionOptionsFrom() | ||||||
---|---|---|---|---|---|---|
Parameters
Returns |
extractDescriptionAndOptionsFrom() | ||||||
---|---|---|---|---|---|---|
Utility method used to extract the error description and httpExceptionOptions from the given argument. This is used by inheriting classes to correctly parse both options. |
||||||
Parameters
Returns
|
Constructor
Instantiate a plain HTTP Exception. |
||||||||||||
Parameters
Examples
|
||||||||||||
Usage NotesThe constructor arguments define the response and the HTTP response status code.
By default, the JSON response body contains two properties:
To override the entire JSON response body, pass an object to the The |
Properties
Methods
initCause() |
---|
Configures error chaining support |
ParametersThere are no parameters. Returns
|
initMessage() |
---|
ParametersThere are no parameters. |
initName() |
---|
ParametersThere are no parameters. Returns
|
getResponse() |
---|
getStatus() |
---|
ParametersThere are no parameters. Returns
|