The goog.debug.ErrorReporter Class

goog.debug.ErrorReporter
> goog.events.EventTarget
> goog.Disposable

goog.debug.ErrorReporter(handlerUrl, opt_contextProvider, opt_noAutoProtect)

Constructs an error reporter. Internal Use Only. To install an error reporter see the {@see #install} method below.

handlerUrl {string}
The URL to which all errors will be reported.
opt_contextProvider {function(!Error, !Object.<string, string>)=}
When a report is to be sent to the server, this method will be called, and given an opportunity to modify the context object before submission to the server.
opt_noAutoProtect {boolean=}
Whether to automatically add handlers for onerror and to protect entry points. If apps have other error reporting facilities, it may make sense for them to set these up themselves and use the ErrorReporter just for transmission of reports.

The goog.debug.ErrorReporter.ExceptionEvent Class

Event broadcast when an exception is logged. … more

.addEventListener(type, handler, opt_capture, opt_handlerScope)

Inherited from goog.events.EventTarget .

Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched. Supported for legacy but use goog.events.listen(src, type, handler) instead.

type {string}
The type of the event to listen for.
handler {Function|Object}
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
opt_capture {boolean=}
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope {Object=}
Object in whose scope to call the listener.

.addOnDisposeCallback(callback, opt_scope)

Inherited from goog.Disposable .

Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.

callback {!Function}
The callback function.
opt_scope {Object=}
An optional scope to call the callback in.

.creationStack {string}

Inherited from goog.Disposable .

If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.

.defaultXhrSender(uri, method, content, opt_headers)

Default implemntation of XHR sender interface.

uri {string}
URI to make request to.
method {string}
Send method.
content {string}
Post data.
opt_headers {Object|goog.structs.Map=}
Map of headers to add to the request.

.dispatchEvent(e)

Inherited from goog.events.EventTarget .

Dispatches an event (or event like object) and calls all listeners listening for events of this type. The type of the event is decided by the type property on the event object. If any of the listeners returns false OR calls preventDefault then this function will return false. If one of the capture listeners calls stopPropagation, then the bubble listeners won't fire.

e {string|Object|goog.events.Event}
Event object.
returns {boolean}
If anyone called preventDefault on the event object (or if any of the handlers returns false this will also return false.

.dispose()

Inherited from goog.Disposable .

Disposes of the object. If the object hasn't already been disposed of, calls {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should override {@link #disposeInternal} in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.

returns {void}
Nothing.

.getParentEventTarget()

Inherited from goog.events.EventTarget .

Returns the parent of this event target to use for bubbling.

returns {goog.events.EventTarget}
The parent EventTarget or null if there is no parent.

.handleException(e, opt_context)

Handler for caught exceptions. Sends report to the LoggingServlet and notifies any listeners.

e {Object}
The exception.
opt_context {!Object.<string, string>=}
Context values to optionally include in the error report.

.install(loggingUrl, opt_contextProvider, opt_noAutoProtect)

Installs an error reporter to catch all JavaScript errors raised.

loggingUrl {string}
The URL to which the errors caught will be reported.
opt_contextProvider {function(!Error, !Object.<string, string>)=}
When a report is to be sent to the server, this method will be called, and given an opportunity to modify the context object before submission to the server.
opt_noAutoProtect {boolean=}
Whether to automatically add handlers for onerror and to protect entry points. If apps have other error reporting facilities, it may make sense for them to set these up themselves and use the ErrorReporter just for transmission of reports.
returns {goog.debug.ErrorReporter}
The error reporter.

.isDisposed()

Inherited from goog.Disposable .

returns {boolean}
Whether the object has been disposed of.

.protectAdditionalEntryPoint(fn)

Installs exception protection for an entry point function in addition to those that are protected by default. Has no effect in IE because window.onerror is used for reporting exceptions in that case.

fn {Function}
An entry point function to be protected.
returns {Function}
A protected wrapper function that calls the entry point function or null if the entry point could not be protected.

.registerDisposable(disposable)

Inherited from goog.Disposable .

Associates a disposable object with this object so that they will be disposed together.

disposable {goog.disposable.IDisposable}
that will be disposed when this object is disposed.

.removeEventListener(type, handler, opt_capture, opt_handlerScope)

Inherited from goog.events.EventTarget .

Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.

type {string}
The type of the event to listen for.
handler {Function|Object}
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
opt_capture {boolean=}
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope {Object=}
Object in whose scope to call the listener.

.sendErrorReport(message, fileName, line, opt_trace, opt_context)

Sends an error report to the logging URL. This will not consult the context provider, the report will be sent exactly as specified.

message {string}
Error description.
fileName {string}
URL of the JavaScript file with the error.
line {number}
Line number of the error.
opt_trace {string=}
Call stack trace of the error.
opt_context {!Object.<string, string>=}
Context information to include in the request.

.setLoggingHeaders(loggingHeaders)

Add headers to the logging url.

loggingHeaders {Object|goog.structs.Map}
Extra headers to send to the logging URL.

.setParentEventTarget(parent)

Inherited from goog.events.EventTarget .

Sets the parent of this event target to use for bubbling.

parent {goog.events.EventTarget?}
Parent EventTarget (null if none).

.setXhrSender(xhrSender)

Set the function used to send error reports to the server.

xhrSender {function(string, string, string, (Object|goog.structs.Map)=)}
If provided, this will be used to send a report to the server instead of the default method. The function will be given the URI, HTTP method request content, and (optionally) request headers to be added.