JS_ReportErrorNumber

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_ReportErrorNumber
  • Revision title: JS_ReportErrorNumber
  • Revision id: 138286
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment 79 words added, 30 words removed

Revision Content

{{ Jsapi_ref_header("JS_ReportErrorNumber") }}

Report an error with an application-defined error code.

Syntax

void JS_ReportErrorNumber(JSContext *cx, JSErrorCallback errorCallback,
    void *userRef, const uintN errorNumber, ...);

void JS_ReportErrorNumberUC(JSContext *cx, JSErrorCallback errorCallback,
    void *userRef, const uintN errorNumber, ...);

JSBool JS_ReportErrorFlagsAndNumber(JSContext *cx, uintN flags,
    JSErrorCallback errorCallback, void *userRef,
    const uintN errorNumber, ...);

JSBool JS_ReportErrorFlagsAndNumberUC(JSContext *cx, uintN flags,
    JSErrorCallback errorCallback, void *userRef,
    const uintN errorNumber, ...);
Name Type Description
cx JSContext * The context in which to report the error. {{ Jsapi-requires-request() }}
flags uintN Error report flags.
errorCallback JSErrorCallback Callback to fetch the error message.
userRef void * A pointer to application data.
errorNumber const uintN An error code.  The JavaScript engine passes this number to errorCallback. The meaning of the error number is application-defined.
... ... Additional arguments for the error message. The number and types of these arguments are determined by the errorCallback.

Description

These functions create a JSErrorReport, populate it with an error message obtained from the specified JSErrorCallback, report it to the current error reporter callback, and possibly create an Error object and set it as the pending exception.

{{ LXRSearch("ident", "i", "JS_ReportErrorNumber") }}
{{ LXRSearch("ident", "i", "JS_ReportErrorNumberUC") }}
{{ LXRSearch("ident", "i", "JS_ReportErrorFlagsAndNumber") }}
{{ LXRSearch("ident", "i", "JS_ReportErrorFlagsAndNumberUC") }}

Revision Source

<p>{{ Jsapi_ref_header("JS_ReportErrorNumber") }}</p>
<p>Report an error with an application-defined error code.</p>
<h2 name="Syntax">Syntax</h2>
<pre class="eval">void <strong>JS_ReportErrorNumber</strong>(<a href="/en/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, <a href="/en/JS_ReportErrorNumber" title="en/JS_ReportErrorNumber">JSErrorCallback</a> errorCallback,
    void *userRef, const <a href="/en/jsint" title="en/jsint">uintN</a> errorNumber, ...);

void <strong>JS_ReportErrorNumberUC</strong>(<a href="/en/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, <a href="/en/JS_ReportErrorNumber" title="en/JS_ReportErrorNumber">JSErrorCallback</a> errorCallback,
    void *userRef, const <a href="/en/jsint" title="en/jsint">uintN</a> errorNumber, ...);

<a href="/en/JSBool" title="en/JSBool">JSBool</a> <strong>JS_ReportErrorFlagsAndNumber</strong>(<a href="/en/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, <a href="/en/jsint" title="en/jsint">uintN</a> flags,
    <a href="/en/JS_ReportErrorNumber" title="en/JS_ReportErrorNumber">JSErrorCallback</a> errorCallback, void *userRef,
    const <a href="/en/jsint" title="en/jsint">uintN</a> errorNumber, ...);

<a href="/en/JSBool" title="en/JSBool">JSBool</a> <strong>JS_ReportErrorFlagsAndNumberUC</strong>(<a href="/en/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, <a href="/en/jsint" title="en/jsint">uintN</a> flags,
    <a href="/en/JS_ReportErrorNumber" title="en/JS_ReportErrorNumber">JSErrorCallback</a> errorCallback, void *userRef,
    const <a href="/en/jsint" title="en/jsint">uintN</a> errorNumber, ...);
</pre>
<table class="fullwidth-table"> <tbody> <tr> <th>Name</th> <th>Type</th> <th>Description</th> </tr> <tr> <td><code>cx</code></td> <td><code><a href="/en/JSRuntime" title="en/JSRuntime">JSContext</a> *</code></td> <td>The context in which to report the error. {{ Jsapi-requires-request() }}</td> </tr> <tr> <td><code>flags</code></td> <td><code><a href="/en/jsint" title="en/jsint">uintN</a></code></td> <td>Error report flags.</td> </tr> <tr> <td><code>errorCallback</code></td> <td><code><a href="/en/JS_ReportErrorNumber" title="en/JS_ReportErrorNumber">JSErrorCallback</a></code></td> <td>Callback to fetch the error message.</td> </tr> <tr> <td><code>userRef</code></td> <td><code>void *</code></td> <td>A pointer to application data.</td> </tr> <tr> <td><code>errorNumber</code></td> <td><code>const <a href="/en/jsint" title="en/jsint">uintN</a></code></td> <td>An error code.  The JavaScript engine passes this number to <code>errorCallback</code>. The meaning of the error number is application-defined.</td> </tr> <tr> <td><code>...</code></td> <td><code>...</code></td> <td>Additional arguments for the error message. The number and types of these arguments are determined by the <code>errorCallback</code>.</td> </tr> </tbody>
</table>
<h2 name="Description">Description</h2>
<p>These functions create a <code><a href="/en/JSErrorReport" title="en/JSErrorReport">JSErrorReport</a></code>, populate it with an error message obtained from the specified <code><a href="/en/JS_ReportErrorNumber" title="en/JS_ReportErrorNumber">JSErrorCallback</a></code>, report it to the current <a class="internal" href="/En/JS%20SetErrorReporter" title="En/JS SetErrorReporter">error reporter callback</a>, and possibly create an <code>Error</code> object and set it as the <a class="internal" href="/En/JS%20SetPendingException" title="En/JS SetPendingException">pending exception</a>.</p>
<p>{{ LXRSearch("ident", "i", "JS_ReportErrorNumber") }}<br>
{{ LXRSearch("ident", "i", "JS_ReportErrorNumberUC") }}<br>
{{ LXRSearch("ident", "i", "JS_ReportErrorFlagsAndNumber") }}<br>
{{ LXRSearch("ident", "i", "JS_ReportErrorFlagsAndNumberUC") }}</p>
Revert to this revision