Merge commit '98293eaa1570b5aff4452021c8b6d6c8560b3f06'

This commit is contained in:
Bjørn Erik Pedersen
2018-07-06 17:53:17 +02:00
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.