Skip to content

Commit b3ebe75

Browse files
committed
* better error reporting in parser gen app
1 parent 8fa00a9 commit b3ebe75

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ParserGenApp/PGDocument.m

+12-2
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,23 @@ - (void)generateWithDestinationPath:(NSString *)destPath parserName:(NSString *)
259259
NSString *path = [[NSString stringWithFormat:@"%@/%@.h", destPath, className] stringByExpandingTildeInPath];
260260
err = nil;
261261
if (![_visitor.interfaceOutputString writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:&err]) {
262-
NSLog(@"%@", err);
262+
NSMutableString *str = [NSMutableString stringWithString:[err localizedFailureReason]];
263+
[str appendFormat:@"\n\n%@", [path stringByDeletingLastPathComponent]];
264+
id dict = [NSMutableDictionary dictionaryWithDictionary:[err userInfo]];
265+
dict[NSLocalizedFailureReasonErrorKey] = str;
266+
self.error = [NSError errorWithDomain:[err domain] code:[err code] userInfo:dict];
267+
goto done;
263268
}
264269

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

271281
done:

0 commit comments

Comments
 (0)