Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit f575ef4

Browse files
deploy-test@travis-ci.orgchirayuk
authored andcommitted
fix(DynamicParser): Correctly handle throwing exceptions from method.
Fixes #971 Closes #1064
1 parent b09f378 commit f575ef4

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

bin/parser_generator_for_spec.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ main(arguments) {
100100
'map["square"] = 6',
101101
'method',
102102
'method()',
103+
'causeException',
104+
'causeException()',
103105
'notAFn()',
104106
'notmixed',
105107
'obj[0].name=1',

lib/core/parser/parser_dynamic.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ class DynamicClosureMap implements ClosureMap {
4545
throw "Property '$name' is not of type function.";
4646
}
4747
} else {
48-
try {
49-
return reflect(o).invoke(symbol, posArgs, sNamedArgs).reflectee;
50-
} on NoSuchMethodError catch (e) {
51-
throw 'Undefined function or exception in $name $e';
52-
}
48+
return reflect(o).invoke(symbol, posArgs, sNamedArgs).reflectee;
5349
}
5450
};
5551
}

test/core/parser/parser_spec.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class TestData {
1010
set str(x) => _str = x;
1111

1212
method() => "testMethod";
13+
causeException() => this.x();
1314
sub1(a, {b: 0}) => a - b;
1415
sub2({a: 0, b: 0}) => a - b;
1516
}
@@ -446,6 +447,12 @@ main() {
446447
expect(context['obj'].field['key']).toEqual(4);
447448
});
448449

450+
it('should rethrow an error from a function', () {
451+
expect(() {
452+
parser("causeException()").eval(new TestData());
453+
}).toThrow('NoSuchMethodError');
454+
});
455+
449456

450457
xit('should throw a nice error for type mismatch', () {
451458
context['obj'] = new SetterObject();

0 commit comments

Comments
 (0)