Home Reference Source
public class | since 0.1.0 | source

HttpError

Extends:

Error → HttpError

Normalised HTTP error class used prior to sending response.

Constructor Summary

Public Constructor
public

constructor(inner: Error, errorType: string, status: number)

since 0.1.0

Member Summary

Public Members
public
public
public
public
public
public

Method Summary

Public Methods
public

Composes a body for the HTTP response to be sent.

since 0.1.0
public

Sets res.statusCode with current instance status and sends a json response with the current instance body.

public

Overrides class instance variables to reflect internal server error.

since 0.1.0

Public Constructors

public constructor(inner: Error, errorType: string, status: number) since 0.1.0 source

Params:

NameTypeAttributeDescription
inner Error

Inner error specific to service (eg. ValidateError).

errorType string

Type of error (eg. 'NAME_NOT_ALLOWED').

status number

Status code.

Public Members

public body: Object source

public errorType: string source

public inner: Error source

public message: string source

public name: string source

public status: string source

Public Methods

public defineBody() since 0.1.0 source

Composes a body for the HTTP response to be sent. If the inner error was a CompilerError, it adds additional compiled and location fields to the body. In all cases, error_type and message are taken from the current HttpError instance.

public sendError(res: Object) source

Sets res.statusCode with current instance status and sends a json response with the current instance body.

Params:

NameTypeAttributeDescription
res Object

Express response object.

public serverError() since 0.1.0 source

Overrides class instance variables to reflect internal server error.