Class: Error

XT. Error

A standard error object. Standard errors are created and pushed into `XT.errors` on application startup. You should use the `clone` function to find and create a copy of an error for use in reporting in the application. Errors may include one or more parameters that can be replaced at runtime to add context to the error message. var params, err; params = { attr: 'name', type: 'String' } err = XT.Error.clone('xt1003', { params: params }); return err.message(); // returns "The value of 'name' must be type: String." Note: You should always use `clone` to make an error rather than reference the error from `XT.errors` directly. Otherwise if you set `params` on the orginial error, you will be setting parameters for that error globally.

new Error()

Source:

Members

code

A unique code for the error.
Source:

messageKey

A translatable text string.
Source:

params

Parameters used for interpreting the text string.
Source:

Methods

clone(Code, Extended) → {XT.Error}

Create a copy of error with `code` found in XT.errors. If an error with a matching code is not found, returns false.
Parameters:
Name Type Description
Code String
Extended Hash properties
Source:
Returns:
Type
XT.Error

create(Extended) → {XT.Error}

Create an instance of `XT.error` extended with `hash`.
Parameters:
Name Type Description
Extended Hash properties
Source:
Returns:
Type
XT.Error

message()

Localized message calculated from `messageKey` and `params`.
Source: