avi*_*i12 4 javascript error-handling excel office-js
我正在开发外接程序,但是遇到错误。
一堆东西被打印到控制台上,其中一些是:

这意味着什么?如何启用该设置?
好问题!
假设您有这样的代码:
async function run() {
await Excel.run(async (context) => {
const range = context.workbook.getSelectedRange();
range.getRow(1000).format.fill.color = "yellow";
await context.sync();
});
}
并想象您的选择范围很小,这样getRow(1000)会导致异常。
如果今天运行此命令,则将获得一些信息:
但请注意,你没有得到完整的语句集,只有“周围”的人(其中,如果你有一个一堆的代码,可能还不够)。而且,某些信息已为您“ ...”编辑。
现在,将以下行粘贴到代码上方:
OfficeExtension.config.extendedErrorLogging = true;
有了它,您将获得完整的错误日志记录(这对于调试非常有用,但是请不要在生产应用程序中执行此操作-您不想支付性能成本,更重要的是,您不需要想要记录和存储敏感数据,这些数据很可能出现在完整语句的日志中(例如,包含客户信息的2D值数组...)
从Office d.ts文件上的DefinitelyTyped:
/** Configuration */
var config: {
/**
* Determines whether to log additional error information upon failure.
*
* When this property is set to true, the error object will include a "debugInfo.fullStatements" property that lists all statements in the batch request, including all statements that precede and follow the point of failure.
*
* Setting this property to true will negatively impact performance and will log all statements in the batch request, including any statements that may contain potentially-sensitive data.
* It is recommended that you only set this property to true during debugging and that you never log the value of error.debugInfo.fullStatements to an external database or analytics service.
*/
extendedErrorLogging: boolean;
};