You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/API.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -331,3 +331,7 @@ await server.stop();
331
331
332
332
<!-- Reference links -->
333
333
[D27]: ./DECISIONS.md
334
+
335
+
## Error Diagnostics
336
+
337
+
When exceptions are thrown by ES-Runtime during module evaluation or unhandled promise rejections, the original `Error` subclasses and their stack traces are preserved. The CLI automatically extracts these diagnostics and prints them elegantly with ANSI colors. The stack trace will highlight exact lines and columns of errors: `TypeError: message \n at fn (file:line:col)`.
> deferred to Phase 2, when the op system gives a second consumer to design it
36
36
> against; extracting it then must not change the public types. *Reason:*
37
37
> avoid speculative abstraction before there is a second implementor/consumer.
38
-
> -**Uncaught-exception JS class not preserved.**`engine::Error::Execution`
39
-
> carries only the stringified exception message, so it maps to a generic JS
40
-
> `Error` rather than the original subclass (`TypeError`, etc.). *Reason:*
41
-
> reconstructing the class requires reading the thrown object's constructor and
42
-
> re-mapping; deferred to Phase 2 when ops re-enter JS. *Impact:* lossy error
43
-
> class on the JS round-trip.
38
+
> -~~**Uncaught-exception JS class not preserved.**~~*Resolved (Phase 8):* Exception classes (including `DOMException` names) and JS stack traces (`at fn (file:line:col)`) are now preserved and surfaced through `engine::Error` into the CLI.
44
39
> -**Primitive-only value marshaling.**`engine::Value` marshals JS primitives
45
40
> plus, since Phase 6, `Value::Bytes` (`Uint8Array`/typed-array views, **copied**
46
41
> to/from `Vec<u8>`). Every other value still collapses to
Copy file name to clipboardExpand all lines: docs/SPEC.md
-5Lines changed: 0 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -147,11 +147,6 @@ Productionizing the standalone runtime *and* stabilizing the embeddable API. ESM
147
147
-**`URLPattern`** → later (not covered by the `url` crate). Minor WHATWG URL conformance gaps tracked vs WPT (D18).
148
148
-**ES module loading** — ☑ **implemented**: static `import`/`export`, **dynamic `import()`** (resolving with the module namespace after the imported module fully evaluates; shares instances with static imports via the realm module map), `import.meta.url`, native top-level await, **local `file:` modules** and **`node_modules` resolution for ES module packages** via the capability-checked `ModuleLoader` provider (DECISIONS D21, D22, D23). `exports` resolution covers string targets, the `import`/`default` conditions, and **subpath patterns** (`"./*"`). **Deferred:** import attributes / JSON modules, remote (`http:`) modules, and the remaining `node_modules` edges (full condition precedence beyond `import`/`default`, `imports`/`#internal`, self-reference). **Rejected by design:** CommonJS packages and `node:` builtins (§125).
149
149
-**`reportError` ErrorEvent dispatch** and **sub-millisecond `performance.now`** are minimal in Phase 4; full behavior lands with the event loop / clock refinements.
150
-
-**Error model & diagnostics standardization** → planned, sequenced *after* the in-flight module/perf work. Today an uncaught error surfaces as a stringified message with no stack and a redundant CLI restatement (e.g. `Uncaught: TypeError: …` then `esrun: <file>: module evaluation failed`), provider errors are doubly nested (`module loading failed: provider error: …`), and there is no color. Scope:
151
-
-**Stack traces + source position** — capture and surface the JS stack (`at fn (file:line:col)`) for uncaught exceptions, module top-level throws, and unhandled rejections, via V8's `Message`/`StackTrace` API. Resolves part of the D3a leak ("exception class/stack not preserved"; DECISIONS D3a/D12).
152
-
-**Stable error codes** — a taxonomy on the layer error enums (module not-found / resolution / unsupported-CommonJS / capability-denied / eval-throw …) for tooling and tests, surfaced in messages.
153
-
-**CLI output format** — one coherent error block instead of the current two lines; de-nest provider errors to a single clear line + code; unify the `Uncaught:` / `Uncaught (in promise):` / `esrun: <label>:` prefixes.
154
-
-**Optional color** — red header, dimmed paths/stack, gated on TTY detection and the `NO_COLOR` convention; never colored when piped/redirected.
When an unhandled exception or unhandled promise rejection bubbles to the
20
+
top level, <codeclassName="rounded bg-zinc-100 px-1 py-0.5 text-[13px]">esrun</code>
21
+
elegantly formats the error trace in your CLI:
22
+
</p>
23
+
24
+
<divclassName="mt-4">
25
+
<CodeBlockcode={`error: uncaught exception in my-script.mjs\nTypeError: network connection refused\n at fetchData (file:///path/to/script.mjs:10:5)\n at file:///path/to/script.mjs:2:1`}title="Terminal"lang="text"/>
0 commit comments