In this quick tip we learn all about the element has error event.
Transcript
In this quick tip, we're going to learn about the "An element has an error running a workflow" event. To create this, we first navigate to create a new workflow and then under "Elements," we click "An element has an error running a workflow". We use this to pinpoint errors that are caused from an element that triggers a workflow.
In the event's Property Editor, we have one property called "Element" which we must define so this event knows which element to look for. Now if this element has a workflow that triggers an error, we can catch the error and decide what to do! Most commonly, we would display the error in a friendlier way.
For example, we can catch a Bubble error that would otherwise show in a browser alert. If a user was trying to log in but forgets to enter their password, a browser alert shows. If we catch errors for this button, we can intercept that and show our alert instead.
In our alert we can show a message using the "Current Workflow Error" data source and access the error code, which is a short sentence about the error. Or, we can get the message, which would show us the entire message of the error.
Now if the user forgot to enter their password, our alert shows instead! We can customize this further with what the message says from the Languages sub-tab.
This also includes errors that Bubble doesn't catch, like a bug from the Bubble engine or a bug from a plugin, so you have some ability to control what is displayed if you encountered one.
For error workflows meant to provide a nicer response to unexpected errors, we do not recommend reading data from the database or an external API, because if the error is caused by a network or connectivity issue, the error workflow may also fail if it relies on data that cannot be loaded. If the error workflow fails, the user will see a browser alert.
Catching errors is good practice to create better interactions for users, so try this event out for yourself!
That's it for this quick tip! For more, be sure to check out bubble.io/academy.