Reputation: 4537
I know using try..catch
for async functions doesn't work, and most advice I've read suggests using it inside the passed callback.
However, without control over the async function which throws the exception, what can one do to catch it? In my example it's chrome.bookmarks.create
, which fails on some edge cases.
Upvotes: 0
Views: 242
Reputation: 349032
In Chrome extensions, there are two possible ways of catching asynchronous errors:
window.onerror
.chrome.runtime.lastError
.Upvotes: 1
Reputation: 13240
In general cases there's no way to catch exceptions on third party functions, you'll have to use error handling methods provided by someone else.
In case of Chrome's extension API you have the lastError property. Enjoy.
Upvotes: 0