diff --git a/src/plugins/vis_type_script/public/renderer/index.tsx b/src/plugins/vis_type_script/public/renderer/index.tsx index b102a809b1ed7..85ef0af41e884 100644 --- a/src/plugins/vis_type_script/public/renderer/index.tsx +++ b/src/plugins/vis_type_script/public/renderer/index.tsx @@ -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 = "

" + (e.reason || e.message || e).toString() + "

" + "" + (e.reason || e).stack || '' + ""; + } + window.addEventListener('error', handleGlobalError); + window.addEventListener('unhandledrejection', handleGlobalError);