Permalink
Browse files

Add error handling in -[MLCState loadScript:error:], printing any err…

…ors that occur
  • Loading branch information...
jspahrsummers committed Nov 7, 2011
1 parent 0771025 commit d790fb217f33d4b87cf45d89be2ec61d593f6e19
@@ -326,7 +326,6 @@ - (void)forwardInvocation:(NSInvocation *)invocation {
}
[state popReturnValueForInvocation:invocation];
-
return YES;
}];
}
@@ -199,9 +199,20 @@ - (BOOL)loadScript:(NSString *)source error:(NSError **)error; {
[source pushOntoStack:self];
+ NSError *localError = nil;
+
// on the stack should be:
// { compiler.loadstring, source }
- return [self callFunctionWithArgumentCount:1 resultCount:1 error:error];
+ if (![self callFunctionWithArgumentCount:1 resultCount:1 error:&localError]) {
+ NSLog(@"Could not load script: %@", localError);
+
+ if (error)
+ *error = localError;
+
+ return NO;
+ } else {
+ return YES;
+ }
}];
}

0 comments on commit d790fb2

Please sign in to comment.