Enhancing Error Handling in Bubble
Instead of getting an ugly browser alert like this, wouldn't you rather Bubble send you an email with the error code and error message so that you can debug it and you don't annoy your users with ugly messages that look like they're full of coding jargon? In this Bubble tutorial video, I'm going to show you how to do that. We're going to trigger an email to be sent to myself when my Bubble app has an error like this. In this case, it's an OpenAI error.
Setting Up the Workflow
And so I'm going to click OK on that, close it down. And I can do this by adding in an unhandled error occurs workflow action. This is something that I think a lot of people overlook, but it's really powerful because just simply by having this workflow in place, it's going to stop that browser alert from showing up. And so then I just add in an action so I can add in the send email action, put my own email address in here, subject and body and embody. I can put in the error code and I can put in the error message.
Considerations for Sending Emails
And just a quick word on sending emails, transactional emails in particular with Bubble. First of all, this is happening on the front end. So if I put an email address in here, it needs to be one that I'm happy that if one of my users really dug in with the browser developer tools, they would be able to access it. It's not going to be kept private. They can see it because this is happening in a front end workflow. Also make sure that this workflow action depends on you having the Sengrid API key set up in your settings tab in your Bubble account. If you've not set up the Sengrid API, then you'll need to set up an alternative transaction email provider. And we've got videos covering all of that.
Additional User Experience Considerations
Last thing, in a separate video, you're going to want to add something else in here because at the moment, this is just basically hiding the error from the user and then sending you an email. They're still going to encounter whatever issue is. So in the case that I demonstrated at the start of this video, my OpenAI key has been deleted. OpenAI API key has been deleted. And so my ChatGPT clone isn't going to work. So I suggest that you show them some sort of alerts and you can check out our videos about host notifications to find out how to do that.
Further Learning Resources
And if you're looking for more ways to learn Bubble, look no further than planetnocode.com because you'll find videos there that you cannot find on YouTube. We've got hundreds of Bubble tutorial videos just like this one, ready to accelerate your development journey.