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.
29 lines
1010 B
29 lines
1010 B
name: duk_get_error_code
|
|
|
|
proto: |
|
|
duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t idx);
|
|
|
|
stack: |
|
|
[ ... val! ... ]
|
|
|
|
summary: |
|
|
<p>Map the value at <code>idx</code> to the error codes <code>DUK_ERR_xxx</code>
|
|
based on which <code>Error</code> subclass the value inherits from. For example,
|
|
if the value at the stack top is an user-defined error which inherits from
|
|
<code>ReferenceError</code>, the return value will be <code>DUK_ERR_REFERENCE_ERROR</code>.
|
|
If the value inherits from <code>Error</code> but doesn't inherit from any of
|
|
the standard subclasses (EvalError, RangeError, ReferenceError, SyntaxError,
|
|
TypeError, URIError) <code>DUK_ERR_ERROR</code> is returned.
|
|
If the value is not an object, does not inherit from <code>Error</code>, or
|
|
<code>idx</code> is invalid, returns 0 (= <code>DUK_ERR_NONE</code>).</p>
|
|
|
|
example: |
|
|
if (duk_get_error_code(ctx, -3) == DUK_ERR_URI_ERROR) {
|
|
printf("Invalid URI\n");
|
|
}
|
|
|
|
tags:
|
|
- stack
|
|
- error
|
|
|
|
introduced: 1.1.0
|
|
|