Skip to content

Instantly share code, notes, and snippets.

@mstijak
Created November 13, 2016 21:49
Show Gist options
  • Select an option

  • Save mstijak/715fa2dd3f495a98386c3ebbadbabb8c to your computer and use it in GitHub Desktop.

Select an option

Save mstijak/715fa2dd3f495a98386c3ebbadbabb8c to your computer and use it in GitHub Desktop.

Revisions

  1. mstijak created this gist Nov 13, 2016.
    26 changes: 26 additions & 0 deletions error.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    window.onerror = function (message, url, lineNo, colNo, error) {

    console.log(arguments);

    let container = document.createElement('div');

    container.style.color = 'red';
    container.style.position = 'fixed';
    container.style.background = '#eee';
    container.style.padding = '2em';
    container.style.top = '1em';
    container.style.left = '1em';

    let msg = document.createElement('pre');
    msg.innerText = [
    'Message: ' + message,
    'URL: ' + url,
    'Line: ' + lineNo,
    'Column: ' + colNo,
    'Stack: ' + (error && error.stack)
    ].join('\n');

    container.appendChild(msg);

    document.body.appendChild(container);
    };