| 1 |
--- |
| 2 |
title: fmt.Erroridf |
| 3 |
description: Log a suppressible ERROR from a template. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
aliases: [erroridf] |
| 9 |
returnType: string |
| 10 |
signatures: ['fmt.Erroridf ID FORMAT [INPUT]'] |
| 11 |
aliases: [/functions/erroridf] |
| 12 |
--- |
| 13 |
|
| 14 |
{{% include "/_common/functions/fmt/format-string.md" %}} |
| 15 |
|
| 16 |
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 `ignoreLogs` array in your project configuration. |
| 17 |
|
| 18 |
This template code: |
| 19 |
|
| 20 |
```go-html-template |
| 21 |
{{ erroridf "error-42" "You should consider fixing this." }} |
| 22 |
``` |
| 23 |
|
| 24 |
Produces this console log: |
| 25 |
|
| 26 |
```text |
| 27 |
ERROR You should consider fixing this. |
| 28 |
You can suppress this error by adding the following to your project configuration: |
| 29 |
ignoreLogs = ['error-42'] |
| 30 |
``` |
| 31 |
|
| 32 |
To suppress this message: |
| 33 |
|
| 34 |
{{< code-toggle file=hugo >}} |
| 35 |
ignoreLogs = ["error-42"] |
| 36 |
{{< /code-toggle >}} |
| 37 |
|
| 38 |
[`errorf`]: /functions/fmt/errorf/ |