Reputation: 3
I can see the 'failure' and 'paused' errors when I view stackdrive-logging. I would like a notification, similar to a Browser.msgBox() when any error occurs in the script, so that i can then check the stackdriver-logger for details. I do not need any details, just a simple pop-up notification while working in the spread sheet. I looked at adding a Trigger, but can not making sense of how to implement an [on-ERROR].
Upvotes: 0
Views: 276
Reputation: 1175
Suppose you have onOpen function code such as below:
function onOpen(e) {
var x = 1 / y; // initial code with possible error
}
We can and should handle possible errors by try .. catch
block. Error object e1 contains useful error description, you might want to display it as alert. So the code should be like this one:
function onOpen(e) {
try {
var x = 1 / y; // initial code with possible error
} catch(e1) {
SpreadsheetApp.getUi().alert(e1.message);
}
}
Really it shows alert box with error description after spreadsheet open.
Upvotes: 1