hugo/content/en/functions/fmt/Erroridf.md
Bjørn Erik Pedersen 9b0050e9aa Squashed 'docs/' content from commit 5c085a37b
git-subtree-dir: docs
git-subtree-split: 5c085a37b297bf12f59efeaae591418ec025c10d
2024-01-27 10:48:33 +01:00

1.1 KiB

title description categories keywords action aliases
fmt.Erroridf Log a suppressable ERROR from a template.
aliases related returnType signatures
erroridf
functions/fmt/Errorf
functions/fmt/Warnf
string
fmt.Erroridf ID FORMAT [INPUT]
/functions/erroridf

{{% include "functions/fmt/_common/fmt-layout.md" %}}

The erroridf function evaluates the format string, then prints the result to the ERROR log and fails the build. Unlike the errorf function, you may suppress errors logged by the erroridf function by adding the message ID to the ignoreErrors array in your site configuration.

This template code:

{{ erroridf "error-42" "You should consider fixing this." }}

Produces this console log:

ERROR You should consider fixing this.
You can suppress this error by adding the following to your site configuration:
ignoreErrors = ['error-42']

To suppress this message:

{{< code-toggle file=hugo >}} ignoreErrors = ["error-42"] {{< /code-toggle >}}