|
|
|
name: duk_fatal
|
|
|
|
|
|
|
|
proto: |
|
|
|
|
duk_ret_t duk_fatal(duk_context *ctx, const char *err_msg);
|
|
|
|
|
|
|
|
summary: |
|
|
|
|
<p>Call fatal error handler with an optional message (<code>err_msg</code>
|
|
|
|
may be <code>NULL</code>). Like all strings in Duktape, the error message
|
|
|
|
should be an UTF-8 string, although pure ASCII is strongly recommended.</p>
|
|
|
|
|
|
|
|
<p>A fatal error handler never returns and may e.g. exit the current
|
|
|
|
process. Error catching points (like <code>try-catch</code> statements
|
|
|
|
and error catching API calls) are bypassed, and finalizers are not executed.
|
|
|
|
You should only call this function when a truly fatal, unrecoverable error
|
|
|
|
has occurred.</p>
|
|
|
|
|
|
|
|
<p>Even though the function never returns, the prototype describes a return
|
|
|
|
value which allows code such as:</p>
|
|
|
|
<pre class="c-code">
|
|
|
|
if (argvalue < 0) {
|
|
|
|
return duk_fatal(ctx, "argvalue invalid, cannot continue execution");
|
|
|
|
}
|
|
|
|
|
|
|
|
example: |
|
|
|
|
duk_fatal(ctx, "assumption failed");
|
|
|
|
|
|
|
|
tags:
|
|
|
|
- error
|
|
|
|
|
|
|
|
introduced: 1.0.0
|