The "error" tag

If the conditions are such that your task should not move forward, and no actions should be executed, it's appropriate to show the user an error message.

We support this using vanilla JSON:

{"error": "Something went wrong!"}

We also support more complex data:

  "error": {
    "message": "Something went wrong!",
    "number_of_things_wrong": 12

As with the "action" tag, we offer the "error" tag as a shorthand for generating these structures.


Block syntax

Using unadorned error and enderror tags, provide your own valid JSON content.

{% error %}
  {{ "There are " | append: count | append: " things you should know!" | json }}
{% enderror %}

When rendered, this becomes:

{"error": "There are 12 things you should know!"}

Tag syntax

Using only an error tag, provide either an array of arguments, or a hash of arguments:

{% error "Something went wrong!" %}
{% error more_details %}
{% error "Something went wrong!", more_details %}
{% error message: "Something went wrong!", details: more_details %}
{"error": "Something went wrong!"}
{"error": {"more": "details"}}
{"error": ["Something went wrong!", {"more": "details"}]}
{"error": {"message": "Something went wrong!", "details": {"more": "details"}}}

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.