@absolunet/ioc2.1.0

View on GitHub

HttpErrorMapper

HTTP errors helper that maps error with HTTP status code.

Constructor

new HttpErrorMapper()

Source:

Methods

getErrorFromHttpStatus(status)

Source:
Get an error class based on HTTP status code.
Parameters:
Name Type Description
status number The HTTP status code.
Returns:
The HTTP error class.
Type
http.exceptions.HttpError

getErrorInstanceFromHttpStatus(status, messageopt, …parameters)

Source:
Get an error instance based on HTTP status code.
Parameters:
Name Type Attributes Description
status number The HTTP status code.
message string <optional>
The error message.
parameters * <repeatable>
The error parameters.
Returns:
The HTTP error instance.
Type
http.exceptions.HttpError

getDefaultMessageFromHttpStatus(status)

Source:
Get default message based on HTTP status code.
Parameters:
Name Type Description
status number The HTTP status code.
Returns:
The default HTTP status message.
Type
string

getHttpErrorMapping()

Source:
Get all HTTP error mapped with the appropriate HTTP status code.
Returns:
The HTTP error mapping.
Type
object.<number, object.<string, (string|HttpError)>>