{"record":{"id":"304d9b34dbe0e770","repo":"withastro/astro","slug":"compilererror","errorCode":"CompilerError","errorMessage":"${compilerError.text}","messagePattern":"\\$\\{compilerError\\.text\\}","errorType":"exception","errorClass":"CompilerError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/compile/compile.ts","lineNumber":100,"sourceCode":"\n\treturn {\n\t\t...transformResult,\n\t\tcss: transformResult.css.map((code, i) => ({\n\t\t\t...cssPartialCompileResults[i],\n\t\t\tcode,\n\t\t})),\n\t};\n}\n\nfunction handleCompileResultErrors(\n\tfilename: string,\n\tresult: TransformResult,\n\tcssTransformErrors: AstroError[],\n) {\n\tconst compilerError = result.diagnostics.find((diag) => diag.severity === 'error');\n\n\tif (compilerError) {\n\t\tthrow new CompilerError({\n\t\t\tname: 'CompilerError',\n\t\t\tmessage: compilerError.text,\n\t\t\tlocation: {\n\t\t\t\tline: compilerError.labels[0].line,\n\t\t\t\tcolumn: compilerError.labels[0].column,\n\t\t\t\tfile: filename,\n\t\t\t},\n\t\t\thint: compilerError.hint,\n\t\t});\n\t}\n\n\tswitch (cssTransformErrors.length) {\n\t\tcase 0:\n\t\t\tbreak;\n\t\tcase 1: {\n\t\t\tthrow cssTransformErrors[0];\n\t\t}\n\t\tdefault: {","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/core/compile/compile.ts#L82-L118","documentation":"Unlike the catch-all `UnknownCompilerError`, this is a structured compiler diagnostic: the compiler returned a `TransformResult` whose `diagnostics` array contains an entry with `severity === 'error'`. The wrapper promotes it into a `CompilerError` with line/column/file/hint extracted from the diagnostic's first label. This is the normal path for syntax errors and template validation failures in `.astro` files.","triggerScenarios":"Authoring a `.astro` file with invalid frontmatter syntax, mismatched JSX-like tags in the template, an unclosed code fence, or disallowed constructs the compiler explicitly rejects.","commonSituations":"Typos in the template (unclosed tags, invalid directive syntax); frontmatter JavaScript syntax errors; using compiler features incorrectly (e.g., malformed `set:html`); copy-paste introducing stray characters.","solutions":["Read the reported line/column in the `.astro` file and fix the syntax error.","Use the diagnostic's `hint` field for suggested fixes.","Run `astro check` for additional TypeScript/diagnostics context.","If the message is unclear, comment out the flagged region and re-add incrementally to isolate the construct."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await astroBuild();\n} catch (e) {\n  if (e.name === 'CompilerError') { /* show e.location, e.hint */ } else throw e;\n}","preventionTips":["Run `astro check` locally before pushing.","Use editor tooling (Astro language server) for live diagnostics.","Keep .astro templates small and syntactically isolated to ease debugging."],"tags":["compiler","build","syntax","astro-file"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}