XMLHttpRequest Network Error Information

I am trying to update some of my add-ons from XUL/XPCOM to WebExtensions and am having some trouble getting the network error information that I want.

Previously (in XUL/XPCOM) I could use the following:

  • Components.interfaces.nsINSSErrorsService,
  • requestChannel.channel.QueryInterface(Components.interfaces.nsIRequest).status, and
  • Components.classes["@mozilla.org/nss_errors_service;1"].getService(localNSSErrorsService).getErrorClass(localErrorStatus);

to provide the required information.

It looks like using WebRequest might provide some of the information I want but I haven’t had any success using it alongside XMLHttpRequest. Do I need to change everything over to WebRequest (I will if I have to - and if it can provide the other details I need - but eveything else is working properly with XMLHttpRequest so I’d prefer not to)?

Can someone, please, provide some pointers/tips/hints on what I should be doing to get the network error information.

Thank you.