I’m writing a fairly large amount of code in Apps Scripts currently, and debugging minor things has become troublesome.
For example, instead of putting "SpreadsheetApp" I put "SpreadsHeetApp", and although I was made aware of this error by Apps Scripts, it did not tell me which line of code this was on!
If you run a single function Apps Scripts provides an Execution log, but this does not seem to be available when you are running it from your sheet.
Am I missing something? Is there a better way to log and read errors in Apps Scripts?
2
Answers
I make it a habit of always wrapping my functions in a try catch block. That way I create a redimentary traceback. You can even create your own error messages as shown in the alternate
debug2
.Code.gs
Executiong log
Alternate debug2
Execution log
Reference
You can find the execution logs by using one of two navigation routes
Open the Google Apps Script project, then click on Executions. This option is located on the sidebar menu, which is initially collapsed. To expand it, hover your cursor over the sidebar and click on the arrow that appears.
Go to https://scripts.google.com, find your project, then click the three dots menu
then click Executions
Another option, might be to use try..catch and set the catch clause to show the error details