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

error() method from fcf.Actions class

Error error()
fcf.Actions error(Error a_error)

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Gets or sets the error in the fcf.Actions object, depending on the arguments passed.

If the a_error parameter is set, then the function sets an error in the fcf.Actions object and returns a pointer to itself

If the a_error parameter is not set, then the function returns the error object that is set in the fcf.Actions object.

If a_error is undefined then the error state is reset

Arguments

Error a_error
- New error value
Result
Error|fcf.Actions
- Returns the current error object set in the fcf.Actions object if the a_error argument is not set.

If the a_error argument is set, then the function returns a pointer to itself

Example: Get error

let actions = new fcf.Actions({quiet: true}); actions.then(()=>{ throw new Error("Test error"); }); console.log(actions.error().message);

Output:

Test error

Example: Set error

let actions = new fcf.Actions({quiet: true}); actions.catch((a_error)=>{ console.log(a_error.message); }); actions.error(new Error("Test error"));

Output:

Test error