AppsScriptPulse

Filter a try/catch error message when coding with Google Apps Script

Search a try/catch error message for keywords to determine the error message to log using JavaScript match.

Filter an error message in a try/catch

Filter an error message in a try/catch

The following Google Apps Script is designed to exercise how you might go about searching the error message in a ‘try/catch’ for keywords. I wanted this specifically for a tool I built that contains a lot of code (and hence a lot of potential error messages) between a try/catch, for which a very small number of people were experiencing a timezone issue with their Google Sheet file.

The aim was to use a JavaScript ‘match’ to find the keyword timezone and display a set of instructions for the user to resolve the issue themselves instead of just a generic error message.

Source: The Gift of Script: Filter a try/catch error message

Leave a Reply

Your email address will not be published. Required fields are marked *