My script has several try-catch block which sends email about the error message. It works but only one simple line of error message is sent. What I want is the line number around the error and more descriptive messages to help me identify where the error is happening.
You can try this (I stole it somewhere), the first converts all info in the catched exception into a string. The second function can be used to wrap some code and if it throws an excetopn write it somewhere.
function catchToString (err) {
var errInfo = "Catched something:\n";
for (var prop in err) {
errInfo += " property: "+ prop+ "\n value: ["+ err[prop]+ "]\n";
}
errInfo += " toString(): " + " value: [" + err.toString() + "]";
return errInfo;
}
function catched (f) {
try {
f ();
}
catch(err) {
Logger.log (catchToString (err));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With