This question is about the Firefox API function:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/sendMessage
Why does browser.tabs.sendMessage() not seem to return a specific error that causes the rejection of the Promise as a reason? Instead, the function appears to return a generic Error and the same message that a specific Error would have.
Is this due to the implementation of sendMessage()? Does it use the generic Error type, because it must be able to return all types of Errors?
I know that https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject says that:
The static
Promise.rejectfunction returns aPromisethat is rejected. For debugging purposes and selective error catching, it is useful to makereasonaninstanceofError.
I would expect to know the specific Error, because if it is just an Error, then I am not sure if it is always easy to understand what causes it.
browser.tabs.sendMessage()so that it looks more like:var atab = browser.tabs; var result = atab.sendMessage(...);. Then inspect what you see inresultif you cause an error insidecontent.js.