fix(change_detection): _throwError should not mask the original exception

This commit is contained in:
vsavkin
2015-09-30 15:28:26 -07:00
parent 5557a5716d
commit cec4b36d9b
5 changed files with 42 additions and 9 deletions

View File

@ -287,11 +287,19 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
}
private _throwError(exception: any, stack: any): void {
var c = this.dispatcher.getDebugContext(this._currentBinding().elementIndex, null);
var context = isPresent(c) ? new _Context(c.element, c.componentElement, c.context, c.locals,
c.injector, this._currentBinding().debug) :
null;
throw new ChangeDetectionError(this._currentBinding().debug, exception, stack, context);
var error;
try {
var c = this.dispatcher.getDebugContext(this._currentBinding().elementIndex, null);
var context = isPresent(c) ? new _Context(c.element, c.componentElement, c.context, c.locals,
c.injector, this._currentBinding().debug) :
null;
error = new ChangeDetectionError(this._currentBinding().debug, exception, stack, context);
} catch (e) {
// if an error happens during getting the debug context, we throw a ChangeDetectionError
// without the extra information.
error = new ChangeDetectionError(null, exception, stack, null);
}
throw error;
}
throwOnChangeError(oldValue: any, newValue: any): void {

View File

@ -254,7 +254,7 @@ export class AppView implements ChangeDispatcher, RenderEventDispatcher {
} catch (e) {
// TODO: vsavkin log the exception once we have a good way to log errors and warnings
// if an error happens during getting the debug context, we return an empty map.
// if an error happens during getting the debug context, we return null.
return null;
}
}