fix(change_detection): throw ChangeDetectionError in JIT mode
This commit is contained in:
@ -309,5 +309,6 @@ var _availableDefinitions = [
|
||||
'sayHi("Jim")',
|
||||
'a()(99)',
|
||||
'a.sayHi("Jim")',
|
||||
'passThrough([12])'
|
||||
'passThrough([12])',
|
||||
'invalidFn(1)'
|
||||
];
|
||||
|
@ -542,16 +542,15 @@ export function main() {
|
||||
});
|
||||
});
|
||||
|
||||
// TODO vsavkin: implement it
|
||||
describe('error handling', () => {
|
||||
xit('should wrap exceptions into ChangeDetectionError', () => {
|
||||
var val = _createChangeDetector('invalidProp');
|
||||
it('should wrap exceptions into ChangeDetectionError', () => {
|
||||
var val = _createChangeDetector('invalidFn(1)');
|
||||
try {
|
||||
val.changeDetector.detectChanges();
|
||||
throw new BaseException('fail');
|
||||
} catch (e) {
|
||||
expect(e).toBeAnInstanceOf(ChangeDetectionError);
|
||||
expect(e.location).toEqual('invalidProp in someComponent');
|
||||
expect(e.location).toEqual('invalidFn(1) in location');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -32,6 +32,7 @@ class _MyComponent_ChangeDetector0 extends _gen.AbstractChangeDetector {
|
||||
final _gen.List<_gen.DirectiveRecord> _directiveRecords;
|
||||
dynamic _locals = null;
|
||||
dynamic _alreadyChecked = false;
|
||||
dynamic currentProto = null;
|
||||
MyComponent _context = null;
|
||||
dynamic _myNum0 = _gen.ChangeDetectionUtil.uninitialized();
|
||||
dynamic _interpolate1 = _gen.ChangeDetectionUtil.uninitialized();
|
||||
@ -44,6 +45,14 @@ class _MyComponent_ChangeDetector0 extends _gen.AbstractChangeDetector {
|
||||
if (!hydrated()) {
|
||||
_gen.ChangeDetectionUtil.throwDehydrated();
|
||||
}
|
||||
try {
|
||||
this.__detectChangesInRecords(throwOnChange);
|
||||
} catch (e, s) {
|
||||
this.throwError(currentProto, e, s);
|
||||
}
|
||||
}
|
||||
|
||||
void __detectChangesInRecords(throwOnChange) {
|
||||
var context = null;
|
||||
var myNum0 = null;
|
||||
var interpolate1 = null;
|
||||
@ -51,7 +60,7 @@ class _MyComponent_ChangeDetector0 extends _gen.AbstractChangeDetector {
|
||||
var change_myNum0 = false;
|
||||
var change_interpolate1 = false;
|
||||
var isChanged = false;
|
||||
var currentProto;
|
||||
currentProto = null;
|
||||
var changes = null;
|
||||
|
||||
context = _context;
|
||||
|
Reference in New Issue
Block a user