Skip to content

Instantly share code, notes, and snippets.

@AdamMadrzejewski
Last active August 29, 2015 14:06
Show Gist options
  • Save AdamMadrzejewski/32b82c3c14b0c3b43cde to your computer and use it in GitHub Desktop.
Save AdamMadrzejewski/32b82c3c14b0c3b43cde to your computer and use it in GitHub Desktop.
function reportError(error, message) {
message = message || '';
console.error(
'ERROR: ' + message + ' [' + error.toString() + ']\n' +
'\nName:\t\t' + (error.name || '-') +
'\nMessage:\t' + (error.message || '-') +
'\nFile:\t\t\t' + (error.fileName || '-') +
'\nSource:\t\t' + ((error.toSource && error.toSource()) || '-') +
'\nLine #:\t\t' + (error.lineNumber || '-') +
'\nColumn #:\t' + (error.columnNumber || '-') +
'\n\nStack:\n\n' + (error.stack || '-'));
}
window.onerror = function (message, filename, lineno, colno, error) {
error.fileName = error.fileName || filename || null;
error.lineNumber = error.lineNumber || lineno || null;
error.columnNumber = error.columnNumber || colno || null;
reportError(error, 'Uncatched Exception');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment