cannot read property "1" from null - Error handling
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2022 07:20 PM
Hi Team,
I have a regex to match something and if the regex doesn't find things, its returning and rest of the code is being ignored.
cannot read property "1" from null
How can I handle this exception instead of getting it errored?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2022 07:33 PM
Hi
how can we help you, if you don't provide the code?
Kind regards
Maik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2022 07:45 PM
2 ways:
1. Check the result of the regex expression before using it. Set the result of .match() or the regex that's being used to a variable and test if this is null. If it is null, skip the remaining code.
2. Surround the script with try {} catch {} block to catch any exception raised by the execution of the script.