Clarify context in example of using the try statement

This commit is contained in:
Joe Mooring
2025-01-18 10:04:38 -08:00
committed by GitHub
parent 56d9c9b711
commit 7c03eb0cc3
+3
View File
@@ -104,6 +104,9 @@ Instead of failing the build, we can catch the error and emit a warning:
{{ end }}
{{ end }}
```
In the above, note that the [context](/getting-started/glossary/#context) within the last conditional block is the `TryValue` object returned by the `try` statement. At this point neither the `Err` nor `Value` methods returned anything, so the current context is not useful. Use the `$` to access the [template context] if needed.
[template context]: /templates/introduction/#template-context
{{% note %}}
Hugo does not classify an HTTP response with status code 404 as an error. In this case `resources.GetRemote` returns nil.