JSErrorReport

Describes the format of a JS error that is used either by the internal error reporting mechanism or by a user-defined error-reporting mechanism.

Syntax

struct JSErrorReport {
    const char      *filename;
    uintN           lineno;
    const char      *linebuf;
    const char      *tokenptr;
    const jschar    *uclinebuf;
    const jschar    *uctokenptr;
    uintN           flags;
    uintN           errorNumber;
    const jschar    *ucmessage;
    const jschar    **messageArgs;
};
Name Type Description
filename const char * Indicates the source file or URL that produced the error condition. If NULL, the error is local to the script in the current HTML page.
lineno uintN Line number in the source that caused the error.
linebuf const char * Text of the line that caused the error, minus the trailing newline character.
tokenptr const char * Pointer to the error token in *linebuf.
uclinebuf const jschar * Unicode line buffer. This is the buffer that contains the original data.
uctokenptr const jschar * Pointer to the error token in *uclinebuf.
flags uintN

The logical OR of zero or more of the following flags:

JSREPORT_WARNING
This "error" is really only a warning. It will not cause the current operation to fail.
JSREPORT_EXCEPTION
An exception is being raised. A JSErrorReporter might choose to ignore a JSErrorReport that has this flag set, since the exception may be caught and handled by JavaScript code.
JSREPORT_STRICT
This error is only being reported because the engine is in strict mode.

The constant JSREPORT_ERROR is 0 and can be used to indicate an error report without any of the above flags.

errorNumber uintN The error number.
ucmessage const jschar * The default unicode error message.
messageArgs const jschar ** Arguments for the error message.

Description

JSErrorReport describes a single error that occurs in the execution of script.

In the event of an error, filename will either contain the name of the external source file or URL containing the script (SCRIPT SRC=) or NULL, indicating that a script embedded in the current HTML page caused the error.

lineno indicates the line number of the script containing the error. In the case of an error in a script embedded in the HTML page, lineno indicates the HTML lineno where the script error is located.

linebuf is a pointer to a user-defined buffer into which JS copies the offending line of the script.

tokenptr is a pointer into linebuf that identifies the precise location line of the problem within the offending line.

uclinebuf is a pointer to a user-defined buffer into which JS copies the Unicode (original) version of the offending line of script.

uctokenptr is a pointer into uclinebuf that identifies the precise location line of the problem within the offending Unicode (original) version of the offending line.

To use JSErrorReport, your application must define a variable of type JSErrorReport and allocate a buffer to hold the text that generated the error condition. Set linebuf to point at the buffer before your application executes a script. For Unicode scripts, define a second buffer that holds the Unicode version of the text the generated the error. For application that do not use Unicode, set uclinebuf and uctokenptr to NULL.

See Also

MXR ID Search for JSErrorReport

JS_ReportError, JS_ReportOutOfMemory, JS_SetErrorReporter, JS_ReportErrorFlagsAndNumber, JS_ReportErrorFlagsAndNumberUC, JS_ReportErrorNumber, JS_ReportErrorNumberUC, JS_ReportPendingException, JS_ReportWarning, JS_ThrowReportedError, JSREPORT_ERROR, JSREPORT_EXCEPTION, JSREPORT_STRICT, JSREPORT_WARNING, JSREPORT_IS_EXCEPTION, JSREPORT_IS_STRICT, JSREPORT_IS_WARNING

Document Tags and Contributors

Contributors to this page: Nickolay, Dria, Callek, Jorend, MMondor
Last updated by: Jorend,