3 options to choose from
Sometimes, data cannot be retrieved and an error is thrown.
For example, JSON API is not accessible, or a file cannot be found to load CSV rows, or a remote database is not accessible because username/password do not match.
For such cases, Twig Anything lets you configure what to do if an error occurs during data retrieval:
The setting can be configured for every template individually. Possible options:
Use cache or display nothing. If there is outdated data in cache, it is used, otherwise nothing is displayed
Use cache or display error. The same as above, will try to use a cached value, even if it has expired; however, if nothing found in cache, an error is displayed.
Always display error. This option will let the template always show the error message; might be useful while your WordPress website is still not so popular and is being actively developed.
The schema below demonstrates what happens behind the scenes every time a Twig template is processed:
As you can see, the logic is not trivial and lets the cache system play well with the error handling engine. However, you won't have to think much about it as it all happens automatically. All you need is to choose one of the 3 options outlined above.
You may also be interested in a topic about how cache works.