goog.debug.ErrorHandler
Provided By | |
---|---|
Extends | |
All Implemented Interfaces |
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.
new ErrorHandler( handler )
Parameters |
|
---|
Instance Methods
this.addOnDisposeCallback<T>( callback, opt_scope ) → void
void
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added. If a callback is added to an already disposed Disposable, it will be called immediately.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.catchUnhandledRejections( win ) → void
void
Install an unhandledrejection event listener that reports rejected promises. Note: this will only work with Chrome 49+ and friends, but so far is the only way to report uncaught errors in aysnc/await functions.
Parameters |
|
---|
this.dispose() → ?
?
Disposes of the object and its resources.
Overrides | ||
---|---|---|
Specified by | ||
Parameters | None. | |
Returns |
|
this.disposeInternal() → void
void
Performs appropriate cleanup. See description of goog.disposable.IDisposable
for examples. 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'); };
Overrides | |
---|---|
Parameters | None. |
this.getDisposed() → boolean
boolean
warning Deprecated | Use |
---|
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getProtectedFunction( fn ) → Function
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 overridden by subclasses
that may want to implement different error handling, or add additional
entry point hooks.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.isDisposed() → boolean
boolean
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.protectEntryPoint( fn ) → Function
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.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.protectWindowRequestAnimationFrame() → void
void
Install exception protection for window.requestAnimationFrame to handle exceptions.
this.protectWindowSetInterval() → void
void
Install exception protection for window.setInterval to handle exceptions.
this.protectWindowSetTimeout() → void
void
Installs exception protection for window.setTimeout to handle exceptions.
this.registerDisposable( disposable ) → void
void
Associates a disposable object with this object so that they will be disposed together.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setPrefixErrorMessages( prefixErrorMessages ) → void
void
Set whether to add a prefix to all error messages that occur in protected functions.
Parameters |
|
---|
this.setWrapErrors( wrapErrors ) → void
void
Set whether to wrap errors that occur in protected functions in a goog.debug.ErrorHandler.ProtectedFunctionError.
Parameters |
|
---|
this.unwrap( fn ) → Function
Function
Try to remove an instrumentation wrapper created by this monitor. If the function passed to unwrap is not a wrapper created by this monitor, then we will do nothing.
Notice that some wrappers may not be unwrappable. For example, if other monitors have applied their own wrappers, then it will be impossible to unwrap them because their wrappers will have captured our wrapper.
So it is important that entry points are unwrapped in the reverse order that they were wrapped.
Specified by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.wrap( fn ) → Function
Function
Instruments a function.
Specified by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
Instance Properties
this.creationStack → (string|undefined)
(string|undefined)
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.