From 28f3a4fa498933da02e74f8b9cc3cd12e0133f45 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 28 May 2008 16:27:14 -0400 Subject: [PATCH] Add better error checking for malformed XML * Source/DebuggerConnection.m: (-[processData:]): If there's an XML error, print a LOT of info about it --- Source/DebuggerConnection.m | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Source/DebuggerConnection.m b/Source/DebuggerConnection.m index 8a94e03..fc75d53 100644 --- a/Source/DebuggerConnection.m +++ b/Source/DebuggerConnection.m @@ -271,15 +271,13 @@ */ - (NSXMLDocument *)processData:(NSData *)data { - NSXMLDocument *doc; - - @try - { - doc = [[NSXMLDocument alloc] initWithData:data options:NSXMLDocumentTidyXML error:nil]; - } - @catch (NSException *e) + NSError *parseError = nil; + NSXMLDocument *doc = [[NSXMLDocument alloc] initWithData:data options:NSXMLDocumentTidyXML error:&parseError]; + if (parseError) { - NSLog(@"Could not parse XML? --- %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); + NSLog(@"Could not parse XML? --- %@", parseError); + NSLog(@"Error UserInfo: %@", [parseError userInfo]); + NSLog(@"This is the XML Document: %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); return nil; } -- 2.22.5