diff --git a/src/transformer.ts b/src/transformer.ts index b6b451f..f87464f 100644 --- a/src/transformer.ts +++ b/src/transformer.ts @@ -153,12 +153,10 @@ export function transformTemplateCode( const matches = [...code.slice(0, start).matchAll(/__pos = (\d+);/g)]; const pos = Number(matches.at(-1)?.[1]); - throw new TransformError({ - message: - `Error transforming template function.\n${message} while transforming:\n\n${annotation}`, - cause: error as ParseError, - pos, - }); + throw new TransformError( + `[meriyah] ${message}\nthrown while parsing compiled template function:\n\n${annotation}`, + { pos }, + ); } const tracker = new ScopeTracker(); @@ -169,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