Permalink
Browse files

catch potential errors when running atos

  • Loading branch information...
1 parent 95ba415 commit 82bd36eecba3c2c9958c2a80e3787d1bdd9763a6 @cppforlife cppforlife committed Feb 18, 2013
Showing with 14 additions and 4 deletions.
  1. +14 −4 Source/CDRSymbolicator.m
View
18 Source/CDRSymbolicator.m
@@ -194,11 +194,21 @@ + (NSString *)shellOutWithCommand:(NSString *)command arguments:(NSArray *)argum
[task setLaunchPath:command];
[task setArguments:arguments];
- NSPipe *pipe = [NSPipe pipe];
- [task setStandardOutput:pipe];
- [task launch];
+ NSPipe *standardOutput = [NSPipe pipe];
+ if (standardOutput) {
+ [task setStandardOutput:standardOutput];
+ } else return nil;
+
+ @try {
+ [task launch];
+ } @catch (NSException *exception) {
+ // e.g. NSInvalidArgumentException reason: 'launch path is invalid'
+ if (exception.name == NSInvalidArgumentException) {
+ return nil;
+ } else @throw;
+ }
- NSData *data = [[pipe fileHandleForReading] readDataToEndOfFile];
+ NSData *data = [[standardOutput fileHandleForReading] readDataToEndOfFile];
[task waitUntilExit];
NSString *string = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];

0 comments on commit 82bd36e

Please sign in to comment.