|
20 | 20 | Learn how to configure a non-root public URL by running `npm run build`. |
21 | 21 | --> |
22 | 22 | <title>CodeRoad</title> |
23 | | -</head> |
24 | | - |
25 | | -<body> |
26 | 23 | <script> |
27 | | -window.onerror=function(message,source,lineno,colno,error){ |
28 | | -console.log(`message:${message}`) |
29 | | -console.log(`source:${source}`) |
30 | | -console.log(`lineno:${lineno},${colno}`) |
31 | | -console.log(`error:${JSON.stringify(error)}`) |
| 24 | +// script must load in the header to work |
| 25 | +window.onerror=function(){ |
| 26 | +// an error bubbled up |
| 27 | +// cannot detect error message as it runs in a different script |
| 28 | +consttargetElement=document.getElementById('coderoad-message') |
| 29 | + |
| 30 | +if(targetElement){ |
| 31 | +// setup failed, display an error message |
| 32 | +document.body.style.padding='1rem' |
| 33 | +document.body.style.border='0.5rem solid #FFBABA' |
| 34 | + |
| 35 | +constdescription=document.createElement('p') |
| 36 | +description.textContent= |
| 37 | +'Try reloading VSCode, if the problem persists please report the error so we can get it fixed at' |
| 38 | +description.style.marginTop='1rem' |
| 39 | +description.style.padding='1rem' |
| 40 | +constlink=document.createElement('a') |
| 41 | +link.href='https://github.com/coderoad/coderoad-vscode/issues' |
| 42 | +link.textContent='github.com/coderoad/coderoad-vscode' |
| 43 | +// append description & link |
| 44 | +targetElement.textContent='Failed to load.' |
| 45 | +targetElement.append(description) |
| 46 | +description.append(document.createElement('br')) |
| 47 | +description.append(link) |
| 48 | +} |
32 | 49 | } |
33 | 50 | </script> |
| 51 | +</head> |
| 52 | + |
| 53 | +<body> |
34 | 54 | <divid="root"> |
35 | | -<divstyle="position: absolute; top:40%; left: 0; right: 0; text-align: center;"> |
| 55 | +<divstyle="position: absolute; top:33%; left: 0; right: 0; text-align: center;"> |
36 | 56 | <h1>CodeRoad</h1> |
37 | | -<h3> |
| 57 | +<h3id="coderoad-message"> |
38 | 58 | Loading... |
39 | 59 | </h3> |
40 | 60 | </div> |
|