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.
aurelie
(Aurélie VIOLETTE)
May 9, 2022, 12:24pm
3
Hey @kevinwasie ,
you can go on the Error tab inside your workflow
and here you have access to the error on the workflow tab
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?
aurelie
(Aurélie VIOLETTE)
May 9, 2022, 1:30pm
5
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.
2 Likes
felixtanhm
(Felix Tan)
November 12, 2022, 3:29am
6
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?
Mael
November 13, 2022, 11:35pm
7
Yes it’s the same behaviour for API error with our plugin REST API
1 Like
Maybe important to add:
Throwing an Error works in the Custom JavaScript action, but apparently not in the Return a value action (which I like to use for js, because it gives me feedback about the state of variables).