All files / src/renderer/lib globalErrorHandling.ts

0% Statements 0/16
0% Branches 0/7
0% Functions 0/4
0% Lines 0/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54                                                                                                           
window.addEventListener("error", (error) => {
  Iif (error.message.indexOf("dead code elimination") > -1) {
    return true;
  }
  error.stopPropagation();
  error.preventDefault();
  document.body.innerHTML = `<div style="width:100%; padding: 20px; user-select: text;">
      <div>
        <h2>${error.message}</h2>
        <p>
          ${error.filename}L:${error.lineno}C:${error.colno}
        </p>     
        <div>
          ${
            error.error &&
            error.error.stack &&
            error.error.stack
              .split("\n")
              .map((line: string) => `<div>${line}</div>`)
              .join("")
          }
        </div>
      </div>       
      </div>
    </div>`;
  return false;
});
 
window.addEventListener("unhandledrejection", (error) => {
  error.stopPropagation();
  error.preventDefault();
  console.log(error);
  document.body.innerHTML = `<div style="width:100%; padding: 20px; user-select: text;">
        <div>
          <h2>Unhandled Promise Rejection</h2>
          <p></p>
          <div>
          ${
            error.reason &&
            error.reason.stack &&
            error.reason.stack
              .split("\n")
              .map((line: string) => `<div>${line}</div>`)
              .join("")
          }
        </div>          
        </div>       
        </div>
      </div>`;
  return false;
});
 
export default window;