Error Handling


msdn - mt616487



Passing an invalid coercion type

As mentioned before, the callback function exposes a result, so we can attach additional behavior to the button to display a status message.

Office.context.document.setSelectedDataAsync(message, 
     { coercionType: Office.CoercionType.Ooxml },
      messageCallback);


If a user attempts to perform the now invalid action, instead of simply failing, they're presented with a helpful error message letting them know something went wrong.


if (asyncResult === Office.AsyncResultStatus.Failed) { 
   var error = asyncResult.error;
   app.showNotification(error.code + " : " + error.name, error.message);
}



more info - simonjaeger.com

function getHostInformation() { 
   var hostInfoValue = session.storage.getItem('hostInfoValue');
   var items = hostInfoValue.split('$');
   if (!items[2]){
      items = hostInfoValue.split('|');
   }

   var hostInfo = {
      type: items[0],
      platform: items[1],
      version: items[2],
      culture: items[3]
   }
   return hostInfo;
}



© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

Next