我已按照https://developers.google.com/datastudio/connector/error-handling#non-admin-messages上的指南将错误从 getData 方法返回给用户。但是,即使使用提供的示例方法向用户抛出错误,我的所有报告仍然会出现一般错误:
记录方法:
/**
* Throws an error that complies with the community connector spec.
* @param {string} message The error message.
* @param {boolean} userSafe Determines whether this message is safe to show
* to non-admin users of the connector. true to show the message, false
* otherwise. false by default.
*/
function throwConnectorError(message, userSafe) {
userSafe = (typeof userSafe !== 'undefined' &&
typeof userSafe === 'boolean') ? userSafe : false;
if (userSafe) {
message = 'DS_USER:' + message;
}
throw new Error(message);
}
调用代码:
try{
//SOME CODE HERE THAT THROWS ERROR
}catch (ex){
logConnectorError("getData: Unexpected Error:", ex);
if (ex.message !== null){
throwConnectorError("Unable to fetch data due to server error: " + ex.message, true);
}
else{
throwConnectorError("Unexpected error: " + ex, true);
}
}
运行时出错:
Error Details
The server encountered an internal error and was unable to complete your request.
Error ID: 0e1e80fb
该系统是否仍在工作,或者是否有一个示例工作连接器我可以查看以查看我是否缺少某些东西?