Halt and catch fire: Difference between revisions
→{{header|jq}}
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
|||
Line 252:
It's probably more effective to use <syntaxhighlight lang="j"> exit 0</syntaxhighlight> -- this approach would eliminate dependence on a variety of implementation details.
=={{header|jq}}==
{{works with|jq}}
Also works with gojq, the Go implementation of jq
The polite way to halt a running jq program is to use `error` or `halt_error`, both of which come in two flavors.
For example:
<syntaxhighlight lang=jq>
"whoops" | error
</syntaxhighlight>
or
<syntaxhighlight lang=jq>
0 | error("whoops")
</syntaxhighlight>
It is worth noting that the text of a run-time error can be captured using `error/1`, e.g.
<pre>
$ jq -n '0 as $x | try (1/$x) catch error("The error text is: \(.)")'
jq: error (at <unknown>): The error text is: number (1) and number (0) cannot be divided because the divisor is zero
</pre>
"Catching fire" is not so easily done.
=={{header|Julia}}==
|