This commit is contained in:
Bjørn Erik Pedersen 2018-07-06 17:53:17 +02:00
commit 0efd374805
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
26 changed files with 270 additions and 56 deletions

View file

@ -1,7 +1,7 @@
---
title: errorf
linktitle: errorf
description: Evaluates a format string and logs it to ERROR.
description: Log ERROR and fail the build from the templates.
date: 2017-09-30
publishdate: 2017-09-30
lastmod: 2017-09-30
@ -18,9 +18,12 @@ deprecated: false
aliases: []
---
`errorf` will evaluate a format string, then output the result to the ERROR log.
This will also cause the build to fail.
`errorf` will evaluate a format string, then output the result to the ERROR log (and only once per error message to avoid flooding the log).
This will also cause the build to fail (the `hugo` command will `exit -1`).
```
{{ errorf "Something went horribly wrong! %s" err }}
{{ errorf "Failed to handle page %q" .Path }}
```
Note that `errorf` supports all the formatting verbs of the [fmt](https://golang.org/pkg/fmt/) package.