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
}