I am working on adding error handling into my Google Sheets based web app. After investigating try/catch blocks, it's clear that it would be best practice to specify what action to take depending on the exact nature of the error. I have begun testing with errors, but I am unable to find a complete resource that details exactly what attributes of the error can be utilized. For reference, here is the try/catch block in my test function:
try{
var url = "jdbc:mysql://"+SERVER+":"+PORT+"/"+DB_DEV;
var conn = Jdbc.getConnection(url, USERNAME, PASSWORD);
// Sends connection to prepare SQL statements
return conn;
} catch(e){
Logger.log(e);
Logger.log(e.stack); // Valid
Logger.log(e.message); // Valid
Logger.log(e.name); // Valid
Logger.log(e.type); // Invalid
return null;
}
In the above example, "stack", "message", and "name" are all valid attributes, but I was only able to find them via trial and error looking through others' example code. My question is - could someone point me in the direction of a resource that would detail error objects in Google Apps Script?
Apps script uses a standard chrome v8 engine based on javascript. All standard properties of the javascript error object are available(i.e., name and message). Some non standard properties like stack is also available on the v8 engine.