| 959 | |
| 960 | // Hide stack lines before the first user code line. |
| 961 | function hideInternalStackFrames(error) { |
| 962 | overrideStackTrace.set(error, (error, stackFrames) => { |
| 963 | let frames = stackFrames; |
| 964 | if (typeof stackFrames === 'object') { |
| 965 | frames = ArrayPrototypeFilter( |
| 966 | stackFrames, |
| 967 | (frm) => !StringPrototypeStartsWith(frm.getFileName() || '', |
| 968 | 'node:internal'), |
| 969 | ); |
| 970 | } |
| 971 | ArrayPrototypeUnshift(frames, error); |
| 972 | return ArrayPrototypeJoin(frames, '\n at '); |
| 973 | }); |
| 974 | } |
| 975 | |
| 976 | // Node uses an AbortError that isn't exactly the same as the DOMException |
| 977 | // to make usage of the error in userland and readable-stream easier. |