Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling extended error logging in Office Add-ins (to see full statements on error object)

I'm developing an add-in and I'm encountering an error.
A bunch of stuff is printed to the console, and some of it is:

What does that mean? How do I enable that setting?

like image 315
avi12 Avatar asked Jun 21 '18 22:06

avi12


People also ask

How do I enable Add-Ins in PowerPoint?

Click File > Options, and then click Add-Ins. In the Manage list, click PowerPoint Add-ins, and then click Go. In the Available Add-Ins list, select the check box next to the add-in that you want to add, and then click Close.

How do you enable all Add-Ins in Excel?

To activate an Excel add-inClick the File tab, click Options, and then click the Add-Ins category. In the Manage box, click Excel Add-ins, and then click Go. The Add-Ins dialog box appears. In the Add-Ins available box, select the check box next to the add-in that you want to activate, and then click OK.

How do I enable advanced logging in Outlook?

In Outlook, go to Tools > Options. On the Other tab, select Advanced Options. Select or clear the Enable logging (troubleshooting) check box. Exit and restart Outlook.


1 Answers

Great question!

Imagine you have code like this:

async function run() {
  await Excel.run(async (context) => {
    const range = context.workbook.getSelectedRange();
    range.getRow(1000).format.fill.color = "yellow";
    await context.sync();
  });
}

And imagine that your selection is only a small range, such that getRow(1000) will cause an exception.

If you run this today, you'll get some information:

Error screenshot

But note that you don't get the full set of statements, only the "surrounding" ones (which, if you had a bunch of code, might not be enough). And also, that some of the information is "..."-ed out for you.

Now, stick the following line somewhere above your code:

OfficeExtension.config.extendedErrorLogging = true;

Once you have that, you'll get full error logging (which is great for debugging, but please don't do this in production apps -- you don't want to pay the performance cost, and more importantly, you don't want to log and store sensitive data, which might well be present in the log of the full statements (e.g., a 2D values array containing customer info...)

Full statements, after enabling "OfficeExtension.config.extendedErrorLogging"

From the Office d.ts file on 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;
};
like image 127
Michael Zlatkovsky - Microsoft Avatar answered Sep 17 '22 16:09

Michael Zlatkovsky - Microsoft