---
title: "Filter a try/catch error message when coding with Google Apps Script"
author: "Phil Bainbridge"
date: 2022-11-23T20:08:41+00:00
modified: 2022-11-23T20:08:57+00:00
canonical_url: https://pulse.appsscript.info/p/2022/11/filter-a-try-catch-error-message-when-coding-with-google-apps-script/
markdown_url: https://pulse.appsscript.info/p/2022/11/filter-a-try-catch-error-message-when-coding-with-google-apps-script.md
categories:
  - "Beginner"
  - "Snippet"
tags:
  - "pbainbridge.co.uk"
featured_image: https://pulse.appsscript.info/files/2022/11/Filter20an20error20message.png
description: "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."
---

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

![Filter a try/catch error message when coding with Google Apps Script](https://pulse.appsscript.info/files/2022/11/Filter20an20error20message.png)

> Search a try/catch error message for keywords to determine the error message to log using JavaScript match.
> [https://www.pbainbridge.co.uk/2022/11/filter-trycatch-error-message.html](https://www.pbainbridge.co.uk/2022/11/filter-trycatch-error-message.html)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*](https://www.pbainbridge.co.uk/2022/11/filter-trycatch-error-message.html)

---

*Published by [Phil Bainbridge](https://pulse.appsscript.info/p/author/phillipbainbridge/) on [Pulse](https://pulse.appsscript.info/). Original article: [https://pulse.appsscript.info/p/2022/11/filter-a-try-catch-error-message-when-coding-with-google-apps-script/](https://pulse.appsscript.info/p/2022/11/filter-a-try-catch-error-message-when-coding-with-google-apps-script/)*
