Skip to content

Instantly share code, notes, and snippets.

@ertrzyiks
Created February 10, 2021 14:54
Show Gist options
  • Save ertrzyiks/8d6d00d8675c9ce951272363480a3530 to your computer and use it in GitHub Desktop.
Save ertrzyiks/8d6d00d8675c9ce951272363480a3530 to your computer and use it in GitHub Desktop.
Chrome extension that throws exception handled by Rollbar

It creates a browser action that throws an exception captured by Rollbar

  1. Go to extensions
  2. Enable developer mode
  3. Load this extensions from a folder
// Called when the user clicks on the browser action icon.
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null, {file: "content_script.js"});
});
;(function() {
const script = document.createElement('script')
script.src = chrome.extension.getURL('inject.js')
document.documentElement.appendChild(script)
})()
throw new Error('Extension error')
{
"name": "Throw error",
"description": "This extension throws exception handled by Rollbar.",
"version": "1.0.0",
"background": {
"scripts": ["background.js"],
"persistent": false
},
"permissions": [
"tabs", "http://*/*", "https://*/*"
],
"browser_action": {
"default_title": "Throw extension error"
},
"web_accessible_resources": [
"inject.js"
],
"manifest_version": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment