Google Apps 脚本中的 'error' 个对象可以访问哪些属性?
What attributes are accessible for 'error' objects in Google Apps Script?
我正在努力将错误处理添加到我的 Google 基于表格的 Web 应用程序中。在研究了 try/catch 块之后,很明显最好根据错误的确切性质指定要采取的操作。我已经开始测试错误,但我无法找到一个完整的资源来详细说明可以使用错误的哪些属性。作为参考,这是我测试函数中的 try/catch 块:
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;
}
在上面的示例中,“stack”、“message”和“name”都是有效的属性,但我只能通过尝试和错误查看其他人的示例代码才能找到它们。我的问题是 - 有人能指出我在 Google Apps 脚本中详细说明错误对象的资源方向吗?
Apps 脚本使用基于 javascript 的标准 chrome v8 引擎。 javascript error object are available(i.e., name
and message
). Some non standard properties like stack
is also available on the v8 engine.
的所有标准属性
我正在努力将错误处理添加到我的 Google 基于表格的 Web 应用程序中。在研究了 try/catch 块之后,很明显最好根据错误的确切性质指定要采取的操作。我已经开始测试错误,但我无法找到一个完整的资源来详细说明可以使用错误的哪些属性。作为参考,这是我测试函数中的 try/catch 块:
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;
}
在上面的示例中,“stack”、“message”和“name”都是有效的属性,但我只能通过尝试和错误查看其他人的示例代码才能找到它们。我的问题是 - 有人能指出我在 Google Apps 脚本中详细说明错误对象的资源方向吗?
Apps 脚本使用基于 javascript 的标准 chrome v8 引擎。 javascript error object are available(i.e., name
and message
). Some non standard properties like stack
is also available on the v8 engine.