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
Handler for exceptions.

Instance Methods

Public Protected Private
disposeInternal()
No description.
code »
getFunctionIndex_(wrapper) string
Get the index for a function. Used for internal indexing.
Arguments:
wrapper : boolean
True for the wrapper; false for the wrapped.
Returns: string  The index where we should store the function in its wrapper/wrapped function.
code »
getProtectedFunction(fn) !Function
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 : !Function
An entry point function to be protected.
Returns: !Function  protected wrapper function.
code »
getStackTraceHolder_(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.
Arguments:
stackTrace : string
The stack trace to create a span for.
Returns: string  A span which can be clicked on to show the stack trace.
code »
protectEntryPoint(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.
Arguments:
fn : Function
An entry point function to be protected.
Returns: !Function  A protected wrapper function that calls the entry point function.
code »
protectWindowFunctionsHelper_(fnName)
Helper function for protecting a function that causes a function to be asynchronously called, for example setTimeout or requestAnimationFrame.
Arguments:
fnName : string
The name of the function to protect.
code »
protectWindowRequestAnimationFrame()
Install exception protection for window.requestAnimationFrame to handle exceptions.
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 : boolean
See above.
code »
setPrefixErrorMessages(prefixErrorMessages)
Set whether to add a prefix to all error messages that occur in protected functions.
Arguments:
prefixErrorMessages : boolean
Whether to add a prefix to error messages.
code »
setWrapErrors(wrapErrors)
Set whether to wrap errors that occur in protected functions in a goog.debug.ErrorHandler.ProtectedFunctionError.
Arguments:
wrapErrors : boolean
Whether to wrap errors.
code »
unwrap()
No description.
code »
wrap()
No description.
code »
addOnDisposeCallback(callbackopt_scope)
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
Arguments:
callback : function(this:T):?
The callback function.
opt_scope : T=
An optional scope to call the callback in.
code »
dispose() void
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: void  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() {
    mypackage.MyClass.base(this, 'constructor');
    // Constructor logic specific to MyClass.
    ...
  };
  goog.inherits(mypackage.MyClass, goog.Disposable);

  mypackage.MyClass.prototype.disposeInternal = function() {
    // Dispose logic specific to MyClass.
    ...
    // Call superclass's disposeInternal at the end of the subclass's, like
    // in C++, to avoid hard-to-catch issues.
    mypackage.MyClass.base(this, 'disposeInternal');
  };
code »
getDisposed() boolean
Use #isDisposed instead. No description.
Returns: boolean  Whether the object has been disposed of.
code »
isDisposed() boolean
No description.
Returns: boolean  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 : goog.disposable.IDisposable
that will be disposed when this object is disposed.
code »

Instance Properties

addTracersToProtectedFunctions_ :
Whether to add tracers when instrumenting entry points.
Code »
constructor :
No description.
Code »
errorHandlerFn_ :
Handler for exceptions, which can do logging, reporting, etc.
Code »
prefixErrorMessages_ :
Whether to add a prefix to all error messages. The prefix is goog.debug.ErrorHandler.ProtectedFunctionError.MESSAGE_PREFIX. This option only has an effect if this.wrapErrors_ is set to false.
Code »
wrapErrors_ :
Whether errors should be wrapped in goog.debug.ErrorHandler.ProtectedFunctionError before rethrowing.
Code »
creationStack :
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
Code »
disposed_ :
Whether the object has been disposed of.
Code »
onDisposeCallbacks_ :
Callbacks to invoke when this object is disposed.
Code »

Static Properties

goog.debug.ErrorHandler.superClass_ :
No description.
Code »

Package debug

Package Reference