应用程序制造商覆盖服务器端错误消息
App maker override server side error message
我在 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" 消息而不是预期的消息。
我已经尝试使用开发者帐户选项,并为此帐户设置管理员角色并执行服务器端脚本,但对于没有管理员角色的用户,错误仍然存在。
我也试过抛出一个自定义异常,但错误在客户端仍然发生了变化。
当用户没有管理员角色时,我可以更改什么以获得预期的消息?
您问题的相关文档位于此处 https://developers.google.com/appmaker/scripting/api/server。基础是你使用:
throw new app.ManagedError('Your custom message here');
我在 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" 消息而不是预期的消息。
我已经尝试使用开发者帐户选项,并为此帐户设置管理员角色并执行服务器端脚本,但对于没有管理员角色的用户,错误仍然存在。
我也试过抛出一个自定义异常,但错误在客户端仍然发生了变化。
当用户没有管理员角色时,我可以更改什么以获得预期的消息?
您问题的相关文档位于此处 https://developers.google.com/appmaker/scripting/api/server。基础是你使用:
throw new app.ManagedError('Your custom message here');