{"record":{"id":"4c0b0219bc38cfe5","repo":"gohugoio/hugo","slug":"q-w","errorCode":null,"errorMessage":"%q: %w","messagePattern":"%q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/page.go","lineNumber":784,"sourceCode":"\ntype renderStringOpts struct {\n\tDisplay string\n\tMarkup  string\n}\n\nvar defaultRenderStringOpts = renderStringOpts{\n\tDisplay: \"inline\",\n\tMarkup:  \"\", // Will inherit the page's value when not set.\n}\n\nfunc (m *pageMetaSource) wrapError(err error, sourceFs afero.Fs) error {\n\tif err == nil {\n\t\tpanic(\"wrapError with nil\")\n\t}\n\n\tif m.f == nil {\n\t\t// No more details to add.\n\t\treturn fmt.Errorf(\"%q: %w\", m.Path(), err)\n\t}\n\n\treturn hugofs.AddFileInfoToError(err, m.f.FileInfo(), sourceFs)\n}\n\n// wrapError adds some more context to the given error if possible/needed\nfunc (ps *pageState) wrapError(err error) error {\n\treturn ps.m.wrapError(err, ps.s.h.SourceFs)\n}\n\nfunc (ps *pageState) getPageInfoForError() string {\n\ts := fmt.Sprintf(\"kind: %q, path: %q\", ps.Kind(), ps.Path())\n\tif ps.File() != nil {\n\t\ts += fmt.Sprintf(\", file: %q\", ps.File().Filename())\n\t}\n\treturn s\n}\n","sourceCodeStart":766,"sourceCodeEnd":802,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/page.go#L766-L802","documentation":"Generic page-error wrapper from pageMetaSource.wrapError when the source file (m.f) is nil (page.go:784). It prepends the page's logical path (%q) to an inner error so the failing page is identifiable even when no file metadata is available to attach a richer file-position annotation.","triggerScenarios":"Any page-level error where the page has no backing FileInfo (m.f == nil) — e.g. a synthetic/adapter page or a page constructed in memory — and wrapError is called to add context. The wrapped %w is the originating error.","commonSituations":"Content-adapter/data-driven pages, headless or programmatic pages, or error paths reached during early page construction before a file is bound. Seeing this often means the real cause is in the inner %w; the path prefix just names the page.","solutions":["Read the inner %w after the colon — that is the actionable error.","If the page is synthetic/adapter-generated, check the data source feeding it.","If you expected a file-backed page, investigate why FileInfo is nil (early construction failure upstream)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := page.WrapError(srcErr); err != nil {\n    // no file metadata; act on errors.Unwrap for the real cause\n    cause := errors.Unwrap(err)\n}","preventionTips":["For synthetic/adapter pages, ensure upstream construction succeeded so the inner error is meaningful.","Use the path prefix in the message to locate the page, then fix the inner cause."],"tags":["page","error-context","wrap"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}