Skip to content

Commit

Permalink
Merge pull request #8 from Dosant/d/2022-04-26-script-based-visualiza…
Browse files Browse the repository at this point in the history
…tions

Add basic error handling logic
  • Loading branch information
drewdaemon authored Apr 28, 2022
2 parents 410a14d + 1939783 commit affc827
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/plugins/vis_type_script/public/renderer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ const getSandboxDocument = (script: string, dependencies: string[], nonce: strin
window.addEventListener('resize', () => onResize(window.innerWidth, window.innerHeight));
function handleGlobalError(e) {
console.error(e);
// TODO a nicer error:
document.body.innerHTML = "<h1>" + (e.reason || e.message || e).toString() + "</h1>" + "<code>" + (e.reason || e).stack || '' + "</code>";
}
window.addEventListener('error', handleGlobalError);
window.addEventListener('unhandledrejection', handleGlobalError);
</script>
<script nonce="${nonce}">window.addEventListener('load', async () => {${script}})</script>
Expand Down

0 comments on commit affc827

Please sign in to comment.