Skip to content

Instantly share code, notes, and snippets.

@feifanzhou
Created November 6, 2014 23:52
Show Gist options
  • Select an option

  • Save feifanzhou/a83153e806b9bbd216ec to your computer and use it in GitHub Desktop.

Select an option

Save feifanzhou/a83153e806b9bbd216ec to your computer and use it in GitHub Desktop.
Post JS errors to server
window.onerror = function(msg, url, line) {
message = 'Javascript error: *' + msg + '* (' + url + ':' + line + ') for session: *' + getCookie('session_code') + '*'
$.post('/alerts', {
message: message
},
function() { console.log('Successfully reported error') }
)
}
@feifanzhou

Copy link
Copy Markdown
Author

@feifanzhou

Copy link
Copy Markdown
Author

session_code is a cookie that refers to the token for tracking logged in users. Useful to determine who hit the error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment