{"record":{"id":"e0ba2bff7b48e3fc","repo":"emberjs/ember.js","slug":"compile-error-template-problem-template-sp-e0ba2b","errorCode":null,"errorMessage":"Compile Error: ${template.problem} @ ${template.span.start}..${template.span.end}","messagePattern":"Compile Error: (.+?) @ (.+?)\\.\\.(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@glimmer/debug-util/lib/template.ts","lineNumber":14,"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;\n  }\n}\n\nexport function isOkHandle(handle: HandleResult): handle is OkHandle {\n  return typeof handle === 'number';\n}","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/emberjs/ember.js/blob/26f97246a8bf2e28edf26ac3093da2e86c04ffc5/packages/@glimmer/debug-util/lib/template.ts#L1-L32","documentation":"unwrapTemplate unwraps a Template result, and if the result is an error variant it throws a Compile Error containing the template's problem and source span. Like unwrapHandle, this converts compiler failures into an explicit runtime exception instead of silently returning a broken template.","triggerScenarios":"Calling unwrapTemplate on a template produced by the Glimmer compiler whose result === 'error' — i.e., the template source failed to parse/compile.","commonSituations":"Template syntax errors in precompiled bundles; dynamically compiled templates (e.g. from user input or CMS content) that are invalid; version mismatch between compiler and syntax features used.","solutions":["Fix the template syntax reported in problem/span","Lint templates with ember-template-lint in CI to catch errors before unwrap","Sanitize/validate dynamically supplied template sources","Upgrade glimmer-vm if the template uses newer syntax than the compiler supports"],"exampleFix":"// before\n{{each items as |item|}}\n  {{item.name}\n// after\n{{#each items as |item|}}\n  {{item.name}}\n{{/each}}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isTemplateOk(t) { return t.result === 'ok'; }","tryCatchPattern":"try {\n  let ok = unwrapTemplate(template);\n} catch (e) {\n  if (String(e.message).startsWith('Compile Error:')) {\n    reportTemplateError(template.problem, template.span);\n  } else { throw e; }\n}","preventionTips":["Check template.result === 'error' before unwrapping when you have access to the result","Lint dynamic template sources before compiling","Pin compiler/syntax versions together"],"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"}