Browse Source

api doc and test for duk_throw

pull/1/head
Sami Vaarala 11 years ago
parent
commit
f6abce34c9
  1. 17
      api-testcases/test-throw.c
  2. 17
      website/api/duk_throw.txt

17
api-testcases/test-throw.c

@ -0,0 +1,17 @@
/*===
rc=1 -> throw me
===*/
int test_1(duk_context *ctx) {
duk_push_string(ctx, "throw me");
duk_throw(ctx);
return 0;
}
void test(duk_context *ctx) {
int rc;
rc = duk_safe_call(ctx, test_1, 0, 1, DUK_INVALID_INDEX);
printf("rc=%d -> %s\n", rc, duk_get_string(ctx, -1));
}

17
website/api/duk_throw.txt

@ -0,0 +1,17 @@
=proto
void duk_throw(duk_context *ctx);
=stack
[ ... val! ]
=summary
<p>Throw the value on top of the stack. This call never returns.</p>
=example
/* Throw a string value; equivalent to the Ecmascript code:
*
* throw "this string is thrown";
*/
duk_push_string(ctx, "this string is thrown");
duk_throw(ctx);
Loading…
Cancel
Save