<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>266943</bug_id>
          
          <creation_ts>2023-12-30 18:51:05 -0800</creation_ts>
          <short_desc>Throwing an Error subclass includes constructor in stacktrace (unlike V8)</short_desc>
          <delta_ts>2025-08-31 07:43:24 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jarred Sumner">jarred</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>mark.lam</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2002320</commentid>
    <comment_count>0</comment_count>
    <who name="Jarred Sumner">jarred</who>
    <bug_when>2023-12-30 18:51:05 -0800</bug_when>
    <thetext>The following code:

```js
class CustomError extends Error {
  constructor(message) {
    super(message);
  }
}

const error = new CustomError(&quot;uh-oh!&quot;);

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.&lt;anonymous&gt; (/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 &lt;anonymous&gt;:7:15
```

Line 7 is the throw statement</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2002533</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-01-02 09:58:32 -0800</bug_when>
    <thetext>&lt;rdar://problem/120375032&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2138433</commentid>
    <comment_count>2</comment_count>
    <who name="Sosuke Suzuki">sosuke</who>
    <bug_when>2025-08-22 23:35:49 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/49808</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2139957</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-08-31 07:43:23 -0700</bug_when>
    <thetext>Committed 299375@main (70c384691cea): &lt;https://commits.webkit.org/299375@main&gt;

Reviewed commits have been landed. Closing PR #49808 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>