mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
877 B
25 lines
877 B
=proto
|
|
int duk_push_error_object(duk_context *ctx, int err_code, const char *fmt, ...);
|
|
|
|
=stack
|
|
[ ... ] -> [ ... err! ]
|
|
|
|
=summary
|
|
<p>Create a new error object and push it to the value stack (the error is not thrown).
|
|
Returns non-negative index (relative to stack bottom) of the pushed error object.</p>
|
|
|
|
<p>The <tt>message</tt> property of the error object will be set to a <tt>sprintf</tt>-formatted
|
|
string using <tt>fmt</tt> and the remaining arguments. The (custom) <tt>code</tt> property
|
|
will be set to <tt>err_code</tt>. The internal prototype for the created error object is chosen
|
|
based on <tt>err_code</tt>. For instance, <tt>DUK_ERR_RANGE_ERROR</tt> causes the built-in
|
|
<tt>RangeError</tt> prototype to be used.</p>
|
|
|
|
=example
|
|
int err_idx;
|
|
|
|
err_idx = duk_push_error_object(ctx, DUK_ERR_TYPE_ERROR, "invalid argument value: %d", arg_value);
|
|
|
|
=tags
|
|
stack
|
|
object
|
|
error
|
|
|