Skip to content

Commit

Permalink
convert all thrown errors in transformer.ts to TransformError ins…
Browse files Browse the repository at this point in the history
…tances prefixed with `[meriyah]` to indicate source of error
  • Loading branch information
noelforte committed Dec 4, 2024
1 parent a9ed438 commit ca834ee
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ export function transformTemplateCode(
const pos = Number(matches.at(-1)?.[1]);

throw new TransformError(
`Error transforming template function.\n${message} while transforming:\n\n${annotation}`,
{ cause: error as ParseError, pos },
`[meriyah] ${message}\nthrown while parsing compiled template function:\n\n${annotation}`,
{ pos },
);
}

Expand All @@ -167,11 +167,11 @@ export function transformTemplateCode(
];

if (parsed.type !== "Program") {
throw new Error("Expected a program");
throw new TransformError("[meriyah] Expected a program");
}

if (parsed.body.length === 0) {
throw new Error("Empty program");
throw new TransformError("[meriyah] Empty program");
}

// Transforms an identifier to a MemberExpression
Expand Down

0 comments on commit ca834ee

Please sign in to comment.