Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with source maps #156

Merged
merged 9 commits into from
Nov 8, 2023
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,22 @@
message: string,
): Error & { code?: string } {
if (isError(originalError)) {
const error: Error & { code?: string } =
Error.length === 2
? // This branch is getting tested by using the Node version that
// supports `cause` on the Error constructor.
// istanbul ignore next
// Also, for some reason `tsserver` is not complaining that the
// Error constructor doesn't support a second argument in the editor,
// but `tsc` does. I'm not sure why, but we disable this in the
// meantime.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
new Error(message, { cause: originalError })
: new ErrorWithCause(message, { cause: originalError });
let error: Error & { code?: string };
// This branch is getting tested by using the Node version that
// supports `cause` on the Error constructor.
// istanbul ignore next

Check failure on line 98 in src/errors.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (16.x)

Delete `·`

Check failure on line 98 in src/errors.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (18.x)

Delete `·`

Check failure on line 98 in src/errors.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (20.x)

Delete `·`
BelfordZ marked this conversation as resolved.
Show resolved Hide resolved
if (Error.length === 2) {
// Also, for some reason `tsserver` is not complaining that the
// Error constructor doesn't support a second argument in the editor,
// but `tsc` does. Error causes are not supported by our current tsc target (ES2020, we need ES2022 to make this work)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
error = new Error(message, { cause: originalError });
} else {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
error = new ErrorWithCause(message, { cause: originalError });
}

if (isErrorWithCode(originalError)) {
error.code = originalError.code;
Expand Down
Loading