Skip to content

Instantly share code, notes, and snippets.

@DWboutin
Last active August 29, 2015 14:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save DWboutin/218164ded690152ce660 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