Fix RuntimeError.from return value (#19777)

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: dylan-conway <dylan-conway@users.noreply.github.com>
This commit is contained in:
Dylan Conway
2025-05-19 17:05:10 -07:00
committed by GitHub
parent 67b64c3334
commit 33be08bde8
2 changed files with 11 additions and 2 deletions

View File

@@ -42,11 +42,11 @@ export default class RuntimeError {
original: Error;
stack: StackFrame[];
static from(error: Error) {
static from(error: Error): RuntimeError {
const runtime = new RuntimeError();
runtime.original = error;
runtime.stack = this.parseStack(error);
return RuntimeError;
return runtime;
}
/**

View File

@@ -0,0 +1,9 @@
import { expect, test } from "bun:test";
import RuntimeError from "../../../packages/bun-error/runtime-error";
test("RuntimeError.from returns instance", () => {
const err = new Error("boom");
const runtime = RuntimeError.from(err);
expect(runtime.original).toBe(err);
expect(Array.isArray(runtime.stack)).toBe(true);
});