cannot read property "1" from null - Error handling

Khanna Ji
Tera Guru

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?

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Hi

how can we help you, if you don't provide the code?

Kind regards
Maik

Hitoshi Ozawa
Giga Sage
Giga Sage

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.