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

Commit

Permalink
fix(DynamicParser): Correctly handle throwing exceptions from method.
Browse files Browse the repository at this point in the history
Fixes #971

Closes #1064
  • Loading branch information
mvuksano authored and chirayuk committed Jul 24, 2014
1 parent 7677453 commit 82ca6ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions bin/parser_generator_for_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ main(arguments) {
'map["square"] = 6',
'method',
'method()',
'causeException',
'causeException()',
'notAFn()',
'notmixed',
'obj[0].name=1',
Expand Down
6 changes: 1 addition & 5 deletions lib/core/parser/parser_dynamic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ class DynamicClosureMap implements ClosureMap {
throw "Property '$name' is not of type function.";
}
} else {
try {
return reflect(o).invoke(symbol, posArgs, sNamedArgs).reflectee;
} on NoSuchMethodError catch (e) {
throw 'Undefined function or exception in $name $e';
}
return reflect(o).invoke(symbol, posArgs, sNamedArgs).reflectee;
}
};
}
Expand Down
7 changes: 7 additions & 0 deletions test/core/parser/parser_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class TestData {
set str(x) => _str = x;

method() => "testMethod";
causeException() => this.x();
sub1(a, {b: 0}) => a - b;
sub2({a: 0, b: 0}) => a - b;
}
Expand Down Expand Up @@ -446,6 +447,12 @@ main() {
expect(context['obj'].field['key']).toEqual(4);
});

it('should rethrow an error from a function', () {
expect(() {
parser("causeException()").eval(new TestData());
}).toThrow('NoSuchMethodError');
});


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

0 comments on commit 82ca6ba

Please sign in to comment.