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 4 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
28 changes: 15 additions & 13 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,21 @@ export function wrapError<Throwable>(
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 });
// 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. Error causes are not supported by our current tsc target (ES2020, we need ES2022 to make this work)
let error: Error & { code?: string };
if (Error.length === 2) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
BelfordZ marked this conversation as resolved.
Show resolved Hide resolved
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