| 1 |
--- |
| 2 |
title: fmt.Errorf |
| 3 |
description: Log an ERROR from a template. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
aliases: [errorf] |
| 9 |
returnType: string |
| 10 |
signatures: ['fmt.Errorf FORMAT [INPUT]'] |
| 11 |
aliases: [/functions/errorf] |
| 12 |
--- |
| 13 |
|
| 14 |
{{% include "/_common/functions/fmt/format-string.md" %}} |
| 15 |
|
| 16 |
The `errorf` function evaluates the format string, then prints the result to the ERROR log and fails the build. |
| 17 |
|
| 18 |
```go-html-template |
| 19 |
{{ errorf "The %q shortcode requires a src argument. See %s" .Name .Position }} |
| 20 |
``` |
| 21 |
|
| 22 |
Use the [`erroridf`][] function to allow optional suppression of specific errors. |
| 23 |
|
| 24 |
[`erroridf`]: /functions/fmt/erroridf/ |