Skip to content

Commit

Permalink
* better error reporting in parser gen app
Browse files Browse the repository at this point in the history
  • Loading branch information
itod committed Mar 30, 2014
1 parent 8fa00a9 commit b3ebe75
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ParserGenApp/PGDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,23 @@ - (void)generateWithDestinationPath:(NSString *)destPath parserName:(NSString *)
NSString *path = [[NSString stringWithFormat:@"%@/%@.h", destPath, className] stringByExpandingTildeInPath];
err = nil;
if (![_visitor.interfaceOutputString writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:&err]) {
NSLog(@"%@", err);
NSMutableString *str = [NSMutableString stringWithString:[err localizedFailureReason]];
[str appendFormat:@"\n\n%@", [path stringByDeletingLastPathComponent]];
id dict = [NSMutableDictionary dictionaryWithDictionary:[err userInfo]];
dict[NSLocalizedFailureReasonErrorKey] = str;
self.error = [NSError errorWithDomain:[err domain] code:[err code] userInfo:dict];
goto done;
}

path = [[NSString stringWithFormat:@"%@/%@.m", destPath, className] stringByExpandingTildeInPath];
err = nil;
if (![_visitor.implementationOutputString writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:&err]) {
NSLog(@"%@", err);
NSMutableString *str = [NSMutableString stringWithString:[err localizedFailureReason]];
[str appendFormat:@"\n\n%@", [path stringByDeletingLastPathComponent]];
id dict = [NSMutableDictionary dictionaryWithDictionary:[err userInfo]];
dict[NSLocalizedFailureReasonErrorKey] = str;
self.error = [NSError errorWithDomain:[err domain] code:[err code] userInfo:dict];
goto done;
}

done:
Expand Down

0 comments on commit b3ebe75

Please sign in to comment.