{"record":{"id":"0c36a3a2a38042a8","repo":"emberjs/ember.js","slug":"compile-error-error-problem-error-span-sta","errorCode":null,"errorMessage":"Compile Error: ${error.problem} @ ${error.span.start}..${error.span.end}","messagePattern":"Compile Error: (.+?) @ (.+?)\\.\\.(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@glimmer/debug-util/lib/template.ts","lineNumber":8,"sourceCode":"import type { ErrHandle, HandleResult, OkHandle, Template, TemplateOk } from '@glimmer/interfaces';\n\nexport function unwrapHandle(handle: HandleResult): number {\n  if (typeof handle === 'number') {\n    return handle;\n  } else {\n    let error = handle.errors[0];\n    throw new Error(`Compile Error: ${error.problem} @ ${error.span.start}..${error.span.end}`);\n  }\n}\n\nexport function unwrapTemplate(template: Template): TemplateOk {\n  if (template.result === 'error') {\n    throw new Error(\n      `Compile Error: ${template.problem} @ ${template.span.start}..${template.span.end}`\n    );\n  }\n\n  return template;\n}\n\nexport function extractHandle(handle: HandleResult): number {\n  if (typeof handle === 'number') {\n    return handle;\n  } else {\n    return handle.handle;","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/emberjs/ember.js/blob/26f97246a8bf2e28edf26ac3093da2e86c04ffc5/packages/@glimmer/debug-util/lib/template.ts#L1-L26","documentation":"unwrapHandle converts a template compilation result into a numeric handle. When compilation failed, the first error's problem message and span are surfaced as a thrown Compile Error so template syntax mistakes fail loudly at build/broccoli time.","triggerScenarios":"Precompiling a .hbs/.gjs template containing a syntax error (unclosed tag, bad mustache, invalid block param) and then calling unwrapHandle (via handle()/layoutHandle()) on the failed result.","commonSituations":"Typo in handlebars syntax; unsupported syntax for the installed Glimmer version; build-time template compilation in ember-cli-build or addon precompilation pipelines.","solutions":["Read the problem and span in the message to locate the template and fix the syntax","Validate the template compiles by rendering it in development where errors surface with better tooling","Check for syntax unsupported by your glimmer-vm version and upgrade if needed","Run the template through the compiler CLI/linter (ember-template-lint) before building"],"exampleFix":"// before (template)\n{{#if foo}}\n  <p>hi\n// after\n{{#if foo}}\n  <p>hi</p>\n{{/if}}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isHandleOk(h) { return typeof h === 'number'; }","tryCatchPattern":"try {\n  let handle = unwrapHandle(result);\n} catch (e) {\n  if (String(e.message).startsWith('Compile Error:')) {\n    console.error('Template failed to compile:', e.message);\n  } else { throw e; }\n}","preventionTips":["Run ember-template-lint in CI on all templates","Compile templates during development to catch syntax errors early","Keep glimmer-vm and template compiler versions in sync"],"tags":["template","compilation","handlebars","syntax","glimmer"],"backgroundTag":"template-compile-error","analyzedSha":"26f97246a8bf2e28edf26ac3093da2e86c04ffc5","analyzedAt":"2026-09-01T05:01:28.182Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}