Skip to content

Instantly share code, notes, and snippets.

@danielabar
Last active August 29, 2015 14:06
Show Gist options
  • Save danielabar/2cff1bafff5d4f0aaa50 to your computer and use it in GitHub Desktop.
Save danielabar/2cff1bafff5d4f0aaa50 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