From 7c03eb0cc35e768bb9cb09b28fa03dc36950cad2 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Sat, 18 Jan 2025 10:04:38 -0800 Subject: [PATCH] Clarify context in example of using the try statement --- content/en/functions/go-template/try.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/content/en/functions/go-template/try.md b/content/en/functions/go-template/try.md index be2101625..997757a83 100644 --- a/content/en/functions/go-template/try.md +++ b/content/en/functions/go-template/try.md @@ -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.