我正在开发一个插件,但是遇到了错误。
控制台输出了很多信息,其中包括:
这是什么意思?我如何启用此设置?
我正在开发一个插件,但是遇到了错误。
控制台输出了很多信息,其中包括:
这是什么意思?我如何启用此设置?
非常好的问题!
想象一下,您有以下代码:
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值数组...)
来源:DefinitelyTyped上的Office d.ts文件
/** 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;
};