mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
9
test/js/bun/runtime-error.test.ts
Normal file
9
test/js/bun/runtime-error.test.ts
Normal 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);
|
||||
});
|
||||
Reference in New Issue
Block a user