1

我在 Google App Maker 上的服务器端错误管理存在问题。

这是我的代码示例

服务器端

function serverSideFn() {
    // Consider the error to be throw.

    if ( anError ) {
        throw new Error("A specific error message");
    }

}

客户端

function clientSideFn() {
    google.script.run
        .withSuccessHandler(function(result) {
            // Success code...
        })
        .withFailureHandler(function(error) {
            console.log(error.message); // The message error here is not the same if I have or not the Admin role.
            showErrorPopup(error.message);
        })
        .serverSideFn();
}

当我使用默认角色 Admin 执行“clientSideFn”功能时,我收到了很好的消息(“A specific error message”),但如果我没有 Admin 角色,我会收到“Server Error”消息而不是预期的消息.

我尝试使用开发人员帐户选项,并将管理员角色设置为此帐户并执行服务器端脚本,但对于没有管理员角色的用户仍然存在错误。

我也尝试抛出自定义异常,但客户端的错误仍然发生变化。

当用户没有管理员角色时,我可以更改什么以获得预期的消息?

4

1 回答 1

0

您问题的相关文档位于此处https://developers.google.com/appmaker/scripting/api/server。基础是您使用:

throw new app.ManagedError('Your custom message here');
于 2019-10-03T17:27:35.677 回答