Home

# Class goog.debug.ErrorHandler

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.

extends goog.Disposable

Instance Method Summary

`disposeInternal()`

Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend {@code goog.Disposable} should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' {@code disposeInternal} method. Everywhere else the public {@code 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.
    ...
    };

| `getFunctionIndex_(boolean wrapper) ⇒ string` Get the index for a function. Used for internal indexing.
| `getProtectedFunction(!Function fn) ⇒ !Function` Helps {@link #protectEntryPoint} by actually creating the protected wrapper function, after {@link #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.
| `getStackTraceHolder_(string stackTrace) ⇒ string` 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.
| `protectEntryPoint(?Function fn) ⇒ !Function` 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.
| `protectWindowFunctionsHelper_(string fnName)` Helper function for protecting setTimeout/setInterval.
| `protectWindowSetInterval()` Install exception protection for window.setInterval to handle exceptions.
| `protectWindowSetTimeout()` Installs exception protection for window.setTimeout to handle exceptions.
| `setAddTracersToProtectedFunctions(boolean newVal)` Enable tracers when instrumenting entry points.