Browse Source

API doc changes for duk_{throw,error,fatal}()

pull/1038/head
Sami Vaarala 8 years ago
parent
commit
a9c7257bea
  1. 10
      website/api/duk_error.yaml
  2. 2
      website/api/duk_error_va.yaml
  3. 9
      website/api/duk_fatal.yaml
  4. 11
      website/api/duk_throw.yaml

10
website/api/duk_error.yaml

@ -1,7 +1,7 @@
name: duk_error
proto: |
void duk_error(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...);
duk_ret_t duk_error(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...);
stack: |
[ ... ] -> [ ... err! ]
@ -20,6 +20,14 @@ summary: |
<code><a href="#duk_push_error_object">duk_push_error_object()</a></code>.
</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 &lt; 0) {
return duk_error(ctx, DUK_ERR_TYPE_ERROR, "invalid argument value: %d", (int) argvalue);
}
</pre>
example: |
duk_error(ctx, DUK_ERR_RANGE_ERROR, "argument out of range: %d", (int) argval);

2
website/api/duk_error_va.yaml

@ -1,7 +1,7 @@
name: duk_error_va
proto: |
void duk_error_va(duk_context *ctx, duk_errcode_t err_code, const char *fmt, va_list ap);
duk_ret_t duk_error_va(duk_context *ctx, duk_errcode_t err_code, const char *fmt, va_list ap);
stack: |
[ ... ] -> [ ... err! ]

9
website/api/duk_fatal.yaml

@ -1,7 +1,7 @@
name: duk_fatal
proto: |
void duk_fatal(duk_context *ctx, const char *err_msg);
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>
@ -14,6 +14,13 @@ summary: |
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 &lt; 0) {
return duk_fatal(ctx, "argvalue invalid, cannot continue execution");
}
example: |
duk_fatal(ctx, "assumption failed");

11
website/api/duk_throw.yaml

@ -1,7 +1,7 @@
name: duk_throw
proto: |
void duk_throw(duk_context *ctx);
duk_ret_t duk_throw(duk_context *ctx);
stack: |
[ ... val! ]
@ -9,6 +9,15 @@ stack: |
summary: |
<p>Throw the value on top of the stack. This call never returns.</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 &lt; 0) {
duk_push_error_object(ctx, DUK_ERR_TYPE_ERROR, "invalid argument: %d", (int) argvalue);
return duk_throw(ctx);
}
</pre>
example: |
/* Throw a string value; equivalent to the Ecmascript code:
*

Loading…
Cancel
Save