Handle tweet errors properly
Context
In Failing to pull embed breaks pipeline jobs (#178 - closed) we fixed the build error by simply ignoring these errors
using Hugo's ignoreErrors
config.
ignoreErrors:
# WARNING: this will ignore any error returned by Hugo's
# GetJSON https://gohugo.io/functions/data/getjson/ function,
# including shortcodes https://gohugo.io/content-management/shortcodes
- error-remote-getjson
Problem
The solution is too broad, meaning that any external request that is made and fails, will be ignored.
For #178 (closed), the problem comes from the twitter.html
template that comes with Hugo.
This template does not seem to handle errors properly.
Solution
The proper solution would be to either:
- Use a custom template for rendering tweets:
- We can define an error ID that can be safely ignored, or
- We handle the error properly and not render the tweet, or
- Render a generic image/tweet instead like a "not found" error
- Alternatively, handle errors upstream and wait until it is fixed.