From fa38499602e616d3cf4c3f85f18df43fea67996f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Spie=C3=9F?= Date: Thu, 7 Jul 2016 17:14:41 +0200 Subject: [PATCH] Add additonal error logging in attachment processing --- Classes/BITCrashManager.m | 18 ++++++++++++++---- Classes/BITCrashManagerPrivate.h | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Classes/BITCrashManager.m b/Classes/BITCrashManager.m index 4cae9868bd..b7567ab829 100644 --- a/Classes/BITCrashManager.m +++ b/Classes/BITCrashManager.m @@ -327,7 +327,7 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf } } -- (void)persistAttachment:(BITHockeyAttachment *)attachment withFilename:(NSString *)filename { +- (BOOL)persistAttachment:(BITHockeyAttachment *)attachment withFilename:(NSString *)filename { NSString *attachmentFilename = [filename stringByAppendingString:@".data"]; NSMutableData *data = [[NSMutableData alloc] init]; NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; @@ -336,7 +336,7 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf [archiver finishEncoding]; - [data writeToFile:attachmentFilename atomically:YES]; + return [data writeToFile:attachmentFilename atomically:YES]; } - (void)persistUserProvidedMetaData:(BITCrashMetaData *)userProvidedMetaData { @@ -756,7 +756,14 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf BITHockeyAttachment *attachment = [self.delegate attachmentForCrashManager:self]; if (attachment && attachment.hockeyAttachmentData) { - [self persistAttachment:attachment withFilename:[_crashesDir stringByAppendingPathComponent: filename]]; + BOOL success = [self persistAttachment:attachment withFilename:[_crashesDir stringByAppendingPathComponent: filename]]; + if (!success) { + BITHockeyLog(@"ERROR: Persisting the crash attachment failed"); + } else { + BITHockeyLog(@"VERBOSE: Crash attachment successfully persisted."); + } + } else { + BITHockeyLog(@"INFO: Crash attachment was nil"); } } @@ -765,7 +772,10 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf options:0 error:&error]; if (plist) { - [plist writeToFile:[_crashesDir stringByAppendingPathComponent: [filename stringByAppendingPathExtension:@"meta"]] atomically:YES]; + BOOL success = [plist writeToFile:[_crashesDir stringByAppendingPathComponent: [filename stringByAppendingPathExtension:@"meta"]] atomically:YES]; + if (!success) { + BITHockeyLog(@"ERROR: Writing crash meta data failed."); + } } else { BITHockeyLog(@"ERROR: Serializing metaDict failed. %@", error); } diff --git a/Classes/BITCrashManagerPrivate.h b/Classes/BITCrashManagerPrivate.h index 5bb40500e2..a7f1111842 100644 --- a/Classes/BITCrashManagerPrivate.h +++ b/Classes/BITCrashManagerPrivate.h @@ -94,7 +94,7 @@ - (NSString *)firstNotApprovedCrashReport; - (void)persistUserProvidedMetaData:(BITCrashMetaData *)userProvidedMetaData; -- (void)persistAttachment:(BITHockeyAttachment *)attachment withFilename:(NSString *)filename; +- (BOOL)persistAttachment:(BITHockeyAttachment *)attachment withFilename:(NSString *)filename; - (BITHockeyAttachment *)attachmentForCrashReport:(NSString *)filename;