Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improved error feedback when invalid plists are provided

git-svn-id: http://svn.textmate.org/branches/WIP/Tools/Dialog2@8993 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
commit 39c79048d95ee5e33c3f2cce9f45ad4d7e9dbdd4 1 parent 0293e68
@ciaran ciaran authored
Showing with 10 additions and 12 deletions.
  1. +7 −1 CLIProxy.mm
  2. +1 −1  TMDCommand.h
  3. +2 −10 TMDCommand.mm
View
8 CLIProxy.mm
@@ -111,7 +111,13 @@ - (void)writeStringToError:(NSString*)text;
- (id)readPropertyListFromInput;
{
- return [TMDCommand readPropertyList:[self inputHandle]];
+ NSString* error = nil;
+ id plist = [TMDCommand readPropertyList:[self inputHandle] error:&error];
+
+ if(error || !plist)
+ [self writeStringToError:error ?: @"unknown error parsing property list\n"];
+
+ return plist;
}
// ================
View
2  TMDCommand.h
@@ -6,7 +6,7 @@
+ (id)objectForCommand:(NSString*)aCommand;
-+ (id)readPropertyList:(NSFileHandle*)aFileHandle;
++ (id)readPropertyList:(NSFileHandle*)aFileHandle error:(NSString**)error;
+ (void)writePropertyList:(id)aPlist toFileHandle:(NSFileHandle*)aFileHandle;
- (NSString *)commandDescription;
View
12 TMDCommand.mm
@@ -20,21 +20,13 @@ + (id)objectForCommand:(NSString*)aCommand
return [Commands objectForKey:aCommand];
}
-+ (id)readPropertyList:(NSFileHandle*)aFileHandle
++ (id)readPropertyList:(NSFileHandle*)aFileHandle error:(NSString**)error;
{
NSData* data = [aFileHandle readDataToEndOfFile];
if([data length] == 0)
return nil;
- NSString* error = nil;
- id plist = [NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListMutableContainersAndLeaves format:nil errorDescription:&error];
-
- if(error || !plist)
- {
- fprintf(stderr, "%s\n", [error UTF8String] ?: "unknown error parsing property list");
- fwrite([data bytes], [data length], 1, stderr);
- fprintf(stderr, "\n");
- }
+ id plist = [NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListMutableContainersAndLeaves format:nil errorDescription:error];
return plist;
}
Please sign in to comment.
Something went wrong with that request. Please try again.