ErrorFormatters Class
Provides functions and mechanisms to serialize errors
Constructor
ErrorFormatters
()
Item Index
Methods
- convertToObject static
- formatForMime static
- get static
- html static
- html static
- html static
- register static
- unregister static
Properties
- ASC static
- DEFAULT_MIME static
- DEFAULTS static
- DESC static
- failedControllerPaths static
- MIME_MAP static
Methods
convertToObject
-
params
Converts an error to a plain object that can be serialized
Parameters:
-
params
Object
Returns:
formatForMime
-
params
-
cb
Formats an error for the provided MIME type
Parameters:
-
params
Object-
mime
StringThe MIME type of the format to render
-
error
ErrorThe error to be rendered
-
[request]
Request optional -
[localization]
Localization optional
-
-
cb
Function
get
-
mime
Retrieves the formatter for the specified MIME type
Parameters:
-
mime
String
Returns:
formatter for the specified MIME. 'undefined' if does not exist.
html
-
params
-
cb
Serializes an error as JSON
Parameters:
-
params
Object-
mime
StringThe MIME type of the format to render
-
error
ErrorThe error to be rendered
-
[request]
Request optional -
[localization]
Localization optional
-
-
cb
Function
html
-
params
-
cb
Serializes an error as HTML
Parameters:
-
params
Object-
mime
StringThe MIME type of the format to render
-
error
ErrorThe error to be rendered
-
[request]
Request optional -
[localization]
Localization optional
-
-
cb
Function
html
-
params
-
cb
Serializes an error as XML
Parameters:
-
params
Object-
mime
StringThe MIME type of the format to render
-
error
ErrorThe error to be rendered
-
[request]
Request optional -
[localization]
Localization optional
-
-
cb
Function
register
-
mime
-
A
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
StringThe mime type to register the provider for
-
A
Functionfunction that takes two parameters. The first is an object that provides the error and the second parameter is the callback.
Returns:
TRUE when the provider was registered, FALSE if not
unregister
-
mime
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
StringThe MIME type to unregister
Returns:
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