HttpException
Defines the base Nest HTTP exception, which is handled by the default Exceptions Handler.
class HttpException extends Error {
static createBody(objectOrErrorMessage: string | object, description?: string, statusCode?: number)
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: Error | undefined
initCause(): void
initMessage()
initName(): void
getResponse(): string | object
getStatus(): number
}
Subclasses
-
BadRequestException
-
UnauthorizedException
-
MethodNotAllowedException
-
NotFoundException
-
ForbiddenException
-
NotAcceptableException
-
RequestTimeoutException
-
ConflictException
-
GoneException
-
PayloadTooLargeException
-
UnsupportedMediaTypeException
-
UnprocessableEntityException
-
InternalServerErrorException
-
NotImplementedException
-
HttpVersionNotSupportedException
-
BadGatewayException
-
ServiceUnavailableException
-
GatewayTimeoutException
-
ImATeapotException
-
PreconditionFailedException
-
MisdirectedException
See also
Static methods
createBody() |
---|
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
Property | Description |
---|---|
cause: Error | undefined
|
Methods
initCause() |
---|
Configures error chaining support |
ParametersThere are no parameters. Returns
|
See: |
initMessage() |
---|
ParametersThere are no parameters. |
initName() |
---|
ParametersThere are no parameters. Returns
|
getResponse() |
---|
ParametersThere are no parameters. Returns
|
getStatus() |
---|
ParametersThere are no parameters. Returns
|