MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / reportTopLevelError

Function reportTopLevelError

test/browser_reporting.js:59–83  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

57}
58
59function reportTopLevelError(e) {
60 // MINIMAL_RUNTIME doesn't handle exit or call the below onExit handler
61 // so we detect the exit by parsing the uncaught exception message.
62 var message = e.message || e;
63 if (globalThis.disableErrorReporting) {
64 console.error(`ignoring top level error: ${message}`);
65 return;
66 }
67 console.error(`got top level error: ${message}`);
68 if (message.includes('unwind')) return;
69 var offset = message.indexOf('exit(');
70 if (offset != -1) {
71 var status = message.substring(offset + 5);
72 offset = status.indexOf(')')
73 status = status.substr(0, offset)
74 console.error(status);
75 var result = `exit:${status}`;
76 } else {
77 if (hasModule) Module['pageThrewException'] = true;
78 result = `exception:${message} / ${e.stack}`;
79 }
80 // FIXME: Ideally we would just reportResultToServer rather than the `maybe`
81 // form but some browser tests currently report exceptions after exit.
82 maybeReportResultToServer(result);
83}
84
85if (typeof window === 'object' && window) {
86 const urlString = window.location.search;

Callers 1

Calls 3

substrMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected