WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
266943
Throwing an Error subclass includes constructor in stacktrace (unlike V8)
https://bugs.webkit.org/show_bug.cgi?id=266943
Summary
Throwing an Error subclass includes constructor in stacktrace (unlike V8)
Jarred Sumner
Reported
2023-12-30 18:51:05 PST
The following code: ```js class CustomError extends Error { constructor(message) { super(message); } } const error = new CustomError("uh-oh!"); throw error; ``` Prints the following in `jsc`: ``` Exception: Error: uh-oh!
CustomError@throw.js
:3:10 global
code@throw.js
:7:30 ``` The first line of the stack trace is `super(message)`, which is not what users want to see. They want to see where the the error was thrown, not the `super` call for the Error subclass. In Node.js/V8, this works as expected - the first line is the one which threw ``` throw error; ^ CustomError: uh-oh! at Object.<anonymous> (/Users/jarred/throw.js:7:15) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) at node:internal/main/run_main_module:28:49 Node.js v21.4.0 ``` Similarly, pasting the snippet into Chrome DevTools reports: ``` VM51:9 Uncaught Error: uh-oh! at <anonymous>:7:15 ``` Line 7 is the throw statement
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2024-01-02 09:58:32 PST
<
rdar://problem/120375032
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug