API Docs for: 0.8.0
Show:

ErrorFormatters Class

Provides functions and mechanisms to serialize errors

Constructor

ErrorFormatters

()

Item Index

Methods

Properties

Methods

convertToObject

(
  • params
)
Object private static

Converts an error to a plain object that can be serialized

Parameters:

  • params Object

Returns:

Object:

formatForMime

(
  • params
  • cb
)
static

Formats an error for the provided MIME type

Parameters:

  • params Object
    • mime String

      The MIME type of the format to render

    • error Error

      The error to be rendered

    • [request] Request optional
    • [localization] Localization optional
  • cb Function

get

(
  • mime
)
Function static

Retrieves the formatter for the specified MIME type

Parameters:

  • mime String

Returns:

Function:

formatter for the specified MIME. 'undefined' if does not exist.

html

(
  • params
  • cb
)
static

Serializes an error as JSON

Parameters:

  • params Object
    • mime String

      The MIME type of the format to render

    • error Error

      The error to be rendered

    • [request] Request optional
    • [localization] Localization optional
  • cb Function

html

(
  • params
  • cb
)
static

Serializes an error as HTML

Parameters:

  • params Object
    • mime String

      The MIME type of the format to render

    • error Error

      The error to be rendered

    • [request] Request optional
    • [localization] Localization optional
  • cb Function

html

(
  • params
  • cb
)
static

Serializes an error as XML

Parameters:

  • params Object
    • mime String

      The MIME type of the format to render

    • error Error

      The error to be rendered

    • [request] Request optional
    • [localization] Localization optional
  • cb Function

register

(
  • mime
  • A
)
Boolean static

Registers a function to be mapped to a given MIME type. The function will be expected to serialize any given Error to the format specified by the MIME type

Parameters:

  • mime String

    The mime type to register the provider for

  • A Function

    function that takes two parameters. The first is an object that provides the error and the second parameter is the callback.

Returns:

Boolean:

TRUE when the provider was registered, FALSE if not

unregister

(
  • mime
)
Boolean static

Unregisters the provider for the given MIME type. If a default MIME type is specified the current formatter will be unregistered and set to the default implementation

Parameters:

  • mime String

    The MIME type to unregister

Returns:

Boolean:

TRUE when the provider was found and unregistered, FALSE if not

Properties

ASC

Integer private static

Ascending index value

DEFAULT_MIME

String private static

The fallback MIME type

DEFAULTS

Object private static

Contains the default mapping of MIME type to function that will serialize the error to that format

DESC

Integer private static

Descending index value

failedControllerPaths

Object private static

MIME_MAP

Object private static

Contains the mapping of MIME type to function that will serialize the error to that format