How to stop the execution of Google Apps Script?

Can I use something like die () (in php) in an Apps Script application? I considered this issue, the most acceptable solution is to throw a new error, but in this case I do not want to receive a Script crash notification (since I'm not the only one who receives them).

I just want to finish the script.

+5
source share
1 answer

You can stop the function that currently works with return . But this will not stop the function, which is called the function with return in it.

Mozilla Developer Documentation - JavaScript

There are situations where you should use break instead of return .

Documentation - Break

Then there are also throw and try, catch , which you should be aware of.

quit documentation - JavaScript

If the code in the try block has an error, it will not kill your program, it will stop the execution of only what is in the try block.

Try catch

+3
source

Source: https://habr.com/ru/post/1209697/


All Articles