Skip to content

Instantly share code, notes, and snippets.

@jessicard
Last active August 29, 2015 14:10
Show Gist options
  • Save jessicard/cb3792fd22a603c028df to your computer and use it in GitHub Desktop.
Save jessicard/cb3792fd22a603c028df to your computer and use it in GitHub Desktop.

Revisions

  1. jessicard revised this gist Nov 27, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions bugsnag-content-scripts.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    // In your extension's index.html you'll also need to include Bugsnag and disable auto-notification:
    // <script src="bugsnag-2.min.js" data-apiKey="your-api-key" data-autoNotify="false">

    // You can then add try/catch blocks in your content scripts, and pass any errors back up to your extension:
  2. jessicard created this gist Nov 26, 2014.
    20 changes: 20 additions & 0 deletions bugsnag-content-scripts.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    // <script src="bugsnag-2.min.js" data-apiKey="your-api-key" data-autoNotify="false">

    // You can then add try/catch blocks in your content scripts, and pass any errors back up to your extension:

    // Inside your content script
    try {
    // Some code in your content scripts
    } catch(e) {
    var exceptionObj = {stack: e.stack, message: e.message, name: e.name};
    chrome.runtime.sendMessage("extension-id", {type: "error", exception: exceptionObj});
    }

    // Then in your extension code you could listen for this message and notify Bugsnag:

    // Inside your extension
    chrome.runtime.onMessage.addListener(function (message) {
    if(message.type == "error") {
    Bugsnag.notifyException(message.exception);
    }
    });