fix(core): ErrorHandler should not rethrow an error by default (#15077) (#15208)

ErrorHandler can not throw errors because it will unsubscribe itself from
the error stream.

Zones captures errors and feed it into NgZone, which than has a Rx Observable
to feed it into ErrorHandler. If the ErroHandler throws, then Rx will teardown
the observable which in essence causes the ErrorHandler to be removed from the
error handling. This implies that the ErrorHandler can never throw errors.

Closes #14949
Closes #15182
Closes #14316
This commit is contained in:
Miško Hevery
2017-03-16 12:58:41 -07:00
committed by Chuck Jazdzewski
parent 492153a986
commit 77fd91d615
5 changed files with 15 additions and 18 deletions

View File

@ -42,12 +42,12 @@ export class ErrorHandler {
*/
_console: Console = console;
/**
* @internal
*/
rethrowError: boolean;
constructor(rethrowError: boolean = true) { this.rethrowError = rethrowError; }
constructor(
/**
* @deprecated since v4.0 parameter no longer has an effect, as ErrorHandler will never
* rethrow.
*/
deprecatedParameter?: boolean) {}
handleError(error: any): void {
const originalError = this._findOriginalError(error);
@ -63,10 +63,6 @@ export class ErrorHandler {
if (context) {
errorLogger(this._console, 'ERROR CONTEXT', context);
}
// We rethrow exceptions, so operations like 'bootstrap' will result in an error
// when an error happens. If we do not rethrow, bootstrap will always succeed.
if (this.rethrowError) throw error;
}
/** @internal */