Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Wrapping callFunctionNamed with a try/catch.

  • Loading branch information...
commit c00dc512d643fd1144cded8580a4b70a1e779588 1 parent 3736a4b
@ccgus authored
Showing with 16 additions and 7 deletions.
  1. +16 −7 src/JSTalk.m
View
23 src/JSTalk.m
@@ -301,17 +301,26 @@ - (BOOL)hasFunctionNamed:(NSString*)name {
- (id)callFunctionNamed:(NSString*)name withArguments:(NSArray*)args {
- [self pushAsCurrentJSTalk];
+ id returnValue = nil;
- id foo = [_mochaRuntime callFunctionWithName:name withArgumentsInArray:args];
+ @try {
+
+ [self pushAsCurrentJSTalk];
+
+ returnValue = [_mochaRuntime callFunctionWithName:name withArgumentsInArray:args];
+
+ if (returnValue == [MOUndefined undefined]) {
+ returnValue = nil;
+ }
+ }
+ @catch (NSException * e) {
+ NSLog(@"Exception: %@", e);
+ [self print:[e description]];
+ }
[self popAsCurrentJSTalk];
- if (foo == [MOUndefined undefined]) {
- return nil;
- }
-
- return foo;
+ return returnValue;
}
Please sign in to comment.
Something went wrong with that request. Please try again.