FCF 2.0 development in progress...
> > > > > >
[News] [JS Packages API] [JS Downloads] [Donate to the project] [Contacts]

catch() method from fcf.Actions class

fcf.Actions catch(function a_cb)
fcf.Actions catch(boolean|object a_options, function a_cb)

Class: fcf.Actions

Package: fcf-framework-core

File: fcf.js

Available from version: 2.0.2

Adds an error handler that is called when an exception occurs or the fcf.Actions.Act.error() method is called in a deferred action.

When the handler is called when an error occurs, exceptions thrown from the handler are not processed and go out

Arguments

function a_cb
- Error handler function. Function signature:

undefined|Error a_cb (Error a_error)

If the function returns an error object, then subsequent calls to error handlers receive the error that the function returned.

boolean|object a_options
- Sets the parameters of the behavior of the catcher of exceptions. The parameter can be:
  • boolean - If true, enables force mode
  • object - An object containing settings:
    • boolean force - If true, the handler will be called even if the error was already handled (or if noexcept is enabled).
    • boolean shadow- If the value is true, the exception is handled, but the "Exception handler exists" flag is not set. In this case, if no other exception handlers have been added, a warning will be issued indicating that the exception was not handled.
Result
fcf.Actions
- Self pointer

Example: Function application

let actions = new fcf.Actions(); await actions .then(()=>{ throw new Error("Some error"); }) .catch((a_error)=>{ console.error("Error:", a_error.message); });

Output:

Error: Some error