debug.ErrorHandler Extends goog.Disposable
The ErrorHandler can be used to to wrap functions with a try/catch statement. If an exception is thrown, the given error handler function will be called. When this object is disposed, it will stop handling exceptions and tracing. It will also try to restore window.setTimeout and window.setInterval if it wrapped them. Notice that in the general case, it is not technically possible to remove the wrapper, because functions have no knowledge of what they have been assigned to. So the app is responsible for other forms of unwrapping.

Inheritance

Constructor

goog.debug.ErrorHandler(handler)

Parameters

handler :
(Function | null)
Handler for exceptions.

Instance Methods

Public Protected Private
disposeInternal()
No description.
code »
getFunctionIndex_(wrapper)
Get the index for a function. Used for internal indexing.
Arguments:
wrapper :
True for the wrapper; false for the wrapped.
Returns:   The index where we should store the function in its wrapper/wrapped function.
code »
getProtectedFunction(fn)
Helps #protectEntryPoint by actually creating the protected wrapper function, after #protectEntryPoint determines that one does not already exist for the given function. Can be overriden by subclasses that may want to implement different error handling, or add additional entry point hooks.
Arguments:
fn :
An entry point function to be protected.
Returns:   protected wrapper function.
code »
getStackTraceHolder_(stackTrace)
Private helper function to return a span that can be clicked on to display an alert with the current stack trace. Newlines are replaced with a placeholder so that they will not be html-escaped.
Arguments:
stackTrace :
The stack trace to create a span for.
Returns:   A span which can be clicked on to show the stack trace.
code »
protectEntryPoint(fn)
Installs exception protection for an entry point function. When an exception is thrown from a protected function, a handler will be invoked to handle it.
Arguments:
fn :
(Function | null)
An entry point function to be protected.
Returns:   A protected wrapper function that calls the entry point function.
code »
protectWindowFunctionsHelper_(fnName)
Helper function for protecting setTimeout/setInterval.
Arguments:
fnName :
The name of the function we're protecting. Must be setTimeout or setInterval.
code »
protectWindowSetInterval()
Install exception protection for window.setInterval to handle exceptions.
code »
protectWindowSetTimeout()
Installs exception protection for window.setTimeout to handle exceptions.
code »
setAddTracersToProtectedFunctions(newVal)
Enable tracers when instrumenting entry points.
Arguments:
newVal :
See above.
code »
unwrap(fn)
No description.
Arguments:
fn :
No description.
code »
wrap(fn)
No description.
Arguments:
fn :
No description.
code »
dispose()
undefined
Disposes of the object. If the object hasn't already been disposed of, calls #disposeInternal. Classes that extend goog.Disposable should override #disposeInternal in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
Returns: 
undefined
  Nothing.
code »
disposeInternal()
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend goog.Disposable should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' disposeInternal method. Everywhere else the public dispose method must be used. For example:
mypackage.MyClass = function() {
goog.base(this);
// Constructor logic specific to MyClass.
...
};
goog.inherits(mypackage.MyClass, goog.Disposable);

mypackage.MyClass.prototype.disposeInternal = function() {
goog.base(this, 'disposeInternal');
// Dispose logic specific to MyClass.
...
};
code »
getDisposed()
Use #isDisposed instead. No description.
Returns:   Whether the object has been disposed of.
code »
isDisposed()
No description.
Returns:   Whether the object has been disposed of.
code »
registerDisposable(disposable)
Associates a disposable object with this object so that they will be disposed together.
Arguments:
disposable :
that will be disposed when this object is disposed.
code »

Instance Properties

addTracersToProtectedFunctions_ :
Whether to add tracers when instrumenting entry points.
Code »
errorHandlerFn_ :
(Function | null)
Handler for exceptions, which can do logging, reporting, etc.
Code »
dependentDisposables_ :
(Array | null)
Disposables that should be disposed when this object is disposed.
Code »
disposed_ :
Whether the object has been disposed of.
Code »

Package debug

Package Reference