Class: ErrorChain

BX.error. ErrorChain

new ErrorChain (location, error, primeErroropt)

ErrorChain object wraps a chain of errors. Creation of the ErrorChain instance is possible without new keyword.
There is available method BX.error() as a shortcut to BX.error.ErrorChain().

Parameters:
Name Type Attributes Description
location string

Name of the module or method where the error has occurred.

error Error | string

Description of the error.

primeError BX.error.ErrorChain | Error | string <optional>

A prime error that caused this exception. (optional)

Examples:

Example 1:

throw BX.error('Application.run()', 'Run method failed.', Error('Something is wrong.'));

Example 2 - without the third parameter:

throw BX.error('Application.run()', 'Run method failed.');
// or better:
throw BX.error('Application.run()', Error('Run method failed.')); // Error object captures the line number and file name

Example 3 - try/catch block:

try {
	// ...
}
catch (e) {
	throw BX.error('Application.run()', Error('Run method failed.'), e); // chaining of the errors
}
Source:

Methods

addError (location, error, primeErroropt)

Adds new error to error list.

Parameters:
Name Type Attributes Description
location string

Name of the module or method where the error has occurred.

error Error | string

Description of the error.

primeError BX.error.ErrorChain | Error | string <optional>

A prime error that caused this exception. (optional)

Source:

getCallStack () → {string}

Returns call stack.

Returns:
  • string
Source:

getErrors () → {Array}

Returns error list.

Returns:
  • Array
Source:

getPrimeError () → {BX.error.ErrorItem|null}

Returns the original error that caused the exception.

Returns:
Source:

toString () → {string}

Returns the error string.

Returns:
  • string
Source: