Workflow Errors

Do we have access to throw errors in a workflow?

For example, I want to create a custom javascript in an Action inside of a workflow.

If that custom javascript fails, I’d like to throw an error and set the error message and error name to a custom value.

I’ve tried just setting the variable with Custom JS like this “context.workflow.error.name = ‘tester error name’”

But, that does not work to throw the error.

And, it only works once the variable has been defined in with another previous error.

Hey @kevinwasie ,
you can go on the Error tab inside your workflow

error_tab

and here you have access to the error on the workflow tab

currentError

Sorry. I didn’t clarify … I want to throw an error and set the message. Not just read it.

I have custom JS in the workflow, and if there is an error in it, I want to throw an error so that WeWeb runs the OnError path.

Does that make sense?

In this case, inside your Javascript, just throw a custom error

throw new Error(“My message”)

You can run it once to have the binding appearing on the error workflow. Your message will be available on Current Error message property.

1 Like

Hello!

Just wanted to jump in here to ask:

Does this apply to API errors too? So if an API returns a 4XX error in a Workflow, that error would appear under the Current Error property?

Yes it’s the same behaviour for API error with our plugin REST API

1 Like