File size: 1,394 Bytes
1b9ed71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/* Shared boot-failure banner for the three read-only view bootstraps

 * (boot-galaxy.js / boot-ladder.js / boot-ontology.js). A `resolveGraph()`

 * rejection (missing/renamed saved model, malformed graph shape) previously

 * propagated unhandled, leaving the page's static shell on screen with no

 * explanation. This renders the specific, actionable error message the

 * loaders already produce, instead of a silently blank page. */
import { esc } from './util.js';

export function showBootError(e) {
  const msg = esc((e && e.message) || String(e));
  const el = document.createElement('div');
  el.setAttribute('role', 'alert');
  el.style.cssText = [
    'position:fixed', 'inset:0', 'z-index:99999',
    'display:flex', 'align-items:center', 'justify-content:center',
    'padding:24px', 'background:#0b0f14', 'color:#f2f4f8',
    'font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif',
  ].join(';');
  el.innerHTML = `<div style="max-width:560px;text-align:center;">

    <div style="font-size:28px;margin-bottom:12px;">⚠️</div>

    <div style="font-weight:600;margin-bottom:8px;">This view couldn't load its model.</div>

    <div style="opacity:.85;">${msg}</div>

  </div>`;
  document.body.innerHTML = '';
  document.body.appendChild(el);
  // still surface it to the console/devtools for anyone debugging further
  console.error(e);
}