Skip to content

Instantly share code, notes, and snippets.

@tomat
Created January 2, 2017 16:00
Show Gist options
  • Save tomat/547c5140462a948311160297735f7483 to your computer and use it in GitHub Desktop.
Save tomat/547c5140462a948311160297735f7483 to your computer and use it in GitHub Desktop.
(function() {
var errorBoxElement = false;
var showError = function(error) {
if (!errorBoxElement) {
errorBoxElement = document.createElement('div');
errorBoxElement.style.position = 'absolute';
errorBoxElement.style.top = '0';
errorBoxElement.style.bottom = '0';
errorBoxElement.style.left = '0';
errorBoxElement.style.right = '0';
errorBoxElement.style.background = 'rgba(255, 0, 0, 0.7)';
errorBoxElement.style.zIndex = 1000000;
errorBoxElement.style.color = '#fff';
errorBoxElement.style.padding = '10px';
document.body.appendChild(errorBoxElement);
}
var errorLine = document.createElement('div');
errorLine.innerHTML = error;
errorBoxElement.appendChild(errorLine);
};
window.onerror = function(errorMsg, url, lineNumber) {
showError('Error: ' + errorMsg + ' Script: ' + url + ' Line: ' + lineNumber);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment