JS_ReportError

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_ReportError
  • Revision title: JS_ReportError
  • Revision id: 138449
  • Created:
  • Creator: Dria
  • Is current revision? No
  • Comment

Revision Content

{{template.Jsapiref()}}

Summary

Creates a formatted error message to pass to a user-defined error reporting function.

Syntax

void JS_ReportError(JSContext *cx, const char *format, ...);
Name Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information.
format const char * Format string to convert into an error message using a standard C sprintf conversion routine.
... Error message variables to insert into the format string.

Description

JS_ReportError converts a format string and its arguments, format, into an error message using a sprintf-like conversion routine. The resulting string is automatically passed to the user-defined error reporting mechanism. That mechanism might display the error message in a console or dialog box window (as in Navigator 2.0 and greater), or might write the error message to an error log file maintained by the application.

Specify an error reporting mechanism for your application using JS_SetErrorReporter.

See Also

Groups Functions
Documents {{template.LXRSearch("ident", "i", "JS_ReportError", "LXR ID Search")}}
Entries

JS_ReportOutOfMemory, JS_SetErrorReporter

Revision Source

<p> 
{{template.Jsapiref()}}
</p>
<h2 name="Summary"> Summary </h2>
<p>Creates a formatted error message to pass to a user-defined error reporting function.
</p>
<h2 name="Syntax"> Syntax </h2>
<pre>void JS_ReportError(JSContext *cx, const char *format, ...);
</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>JSContext *</code></td>
<td>Pointer to a JS context from which to derive runtime information.</td>
</tr>
<tr>
<td><code>format</code></td>
<td><code>const char *</code></td>
<td>Format string to convert into an error message using a standard C <code>sprintf</code> conversion routine.</td>
</tr>
<tr>
<td><code>...</code></td>
<td><code></code></td>
<td>Error message variables to insert into the format string.</td>
</tr>
</tbody></table>
<h2 name="Description"> Description </h2>
<p><code>JS_ReportError</code> converts a format string and its arguments, <code>format</code>, into an error message using a <code>sprintf</code>-like conversion routine. The resulting string is automatically passed to the user-defined error reporting mechanism. That mechanism might display the error message in a console or dialog box window (as in Navigator 2.0 and greater), or might write the error message to an error log file maintained by the application.
</p><p>Specify an error reporting mechanism for your application using <code><a href="en/JS_SetErrorReporter">JS_SetErrorReporter</a></code>.
</p>
<h2 name="See_Also"> See Also </h2>
<table class="fullwidth-table">
<tbody><tr>
<td>Groups</td>
<td><a href="en/JSAPI_Reference#Functions">Functions</a></td>
</tr>
<tr>
<td>Documents</td>
<td>{{template.LXRSearch("ident", "i", "JS_ReportError", "LXR ID Search")}}</td>
</tr>
<tr>
<td>Entries</td>
<td>
<p><a href="en/JS_ReportOutOfMemory">JS_ReportOutOfMemory</a>,
<a href="en/JS_SetErrorReporter">JS_SetErrorReporter</a>
</p>
</td>
</tr>
</tbody></table>
Revert to this revision