【问题标题】:Log full exception on the client side from Google Apps Script back end从 Google Apps 脚本后端记录客户端的完整异常
【发布时间】:2019-05-21 15:27:33
【问题描述】:

我正在尝试调试已发布的插件,但是我从 GAS 后端返回的异常除了从它引发的行和函数之外没有提供太多信息。

有没有办法将更详细的错误描述传回给客户端?

在我的示例中,我调用了函数 testException,它当前所做的只是抛出一个异常。

客户端代码

google.script.run
    .withSuccessHandler(result => console.log(result))
    .withFailureHandler(error => console.error(error))
    .testException();

服务器端代码

function testException() {
    throw new Error('Test message to show on client side');
}

我得到的所有信息如下:

at testException (code:196) (Test Add On) 42bb9613-6241-4ab9-b39f-01fe5c56b060

如果可能,我希望获得与堆栈驱动程序日志记录相同级别的详细信息。甚至只是错误消息“要在客户端显示的测试消息”。

【问题讨论】:

标签: google-apps-script error-handling stackdriver google-apps-script-addon


【解决方案1】:

您可以使用以下命令访问js error object 中的message

console.error(error.message) 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-09
    • 2014-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多