From 2b36711bca5ad24e205ee0371f1cfd903debe502 Mon Sep 17 00:00:00 2001 From: Danish Phiroz Date: Tue, 1 Oct 2024 16:08:55 -0400 Subject: [PATCH 1/3] Potential Fix for Crash --- .../MVMCoreLoadRequestOperation.m | 23 +++++++++++-------- MVMCore/MVMCore/Utility/MVMCoreErrorObject.m | 14 +++++++++++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 801f2d0..bebb54d 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -686,17 +686,20 @@ if (obj && [obj isKindOfClass:[NSDictionary class]]) { NSDictionary *responseInfo = [obj dict:KeyResponseInfo]; - if (![ValueTypeSuccess isEqualToString:[responseInfo string:KeyType]]) { - errorObject = [[MVMCoreLoadHandler sharedGlobal] attachLoadInformation:loadObject toError: - [[MVMCoreErrorObject alloc] - initWithTitle:[responseInfo stringForKey:KeyErrorHeading] - message:[responseInfo stringForKey:KeyUserMessage] - messageToLog:[responseInfo stringForKey:KeyMessage] - code:[[responseInfo string:KeyCode] integerValue] - domain:ErrorDomainServer - location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]]]; + if (responseInfo == nil) { + errorObject = [[MVMCoreLoadHandler sharedGlobal] errorForLoadObject:loadObject withTitle:nil message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorCritical] code:ErrorCodeJSONNotDictionary domain:ErrorDomainSystem]; + }else { + if (![ValueTypeSuccess isEqualToString:[responseInfo string:KeyType]]) { + errorObject = [[MVMCoreLoadHandler sharedGlobal] attachLoadInformation:loadObject toError: + [[MVMCoreErrorObject alloc] + initWithTitle:[responseInfo stringForKey:KeyErrorHeading] + message:[responseInfo stringForKey:KeyUserMessage] + messageToLog:[responseInfo stringForKey:KeyMessage] + code:[[responseInfo string:KeyCode] integerValue] + domain:ErrorDomainServer + location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]]]; + } } - // Caches each dictionary from the array. [[MVMCoreCache sharedCache] addModuleToCache:obj module:key queue:nil waitUntilFinished:YES completionBlock:NULL]; } else { diff --git a/MVMCore/MVMCore/Utility/MVMCoreErrorObject.m b/MVMCore/MVMCore/Utility/MVMCoreErrorObject.m index 9cf85b6..fb9a41a 100644 --- a/MVMCore/MVMCore/Utility/MVMCoreErrorObject.m +++ b/MVMCore/MVMCore/Utility/MVMCoreErrorObject.m @@ -23,8 +23,10 @@ // Initialization code self.title = title; self.messageToDisplay = message; + self.messageToLog = message; self.code = code; self.domain = domain; + self.systemDomain = nil; self.location = location; self.date = [NSDate date]; self.silentError = YES; @@ -32,6 +34,11 @@ [MVMCoreDispatchUtility performSyncBlockOnMainThread:^{ self.applicationState = [UIApplication sharedApplication].applicationState; }]; + self.sessionId = nil; + self.requestId = nil; + self.requestUrl = nil; + self.serverResponseInfo = nil; + self.crashLog = nil; } return self; } @@ -41,9 +48,11 @@ if (self = [super init]) { // Initialization code self.title = title; + self.messageToDisplay = nil; self.messageToLog = messageToLog; self.code = code; self.domain = domain; + self.systemDomain = nil; self.location = location; self.date = [NSDate date]; self.silentError = YES; @@ -51,6 +60,11 @@ [MVMCoreDispatchUtility performSyncBlockOnMainThread:^{ self.applicationState = [UIApplication sharedApplication].applicationState; }]; + self.sessionId = nil; + self.requestId = nil; + self.requestUrl = nil; + self.serverResponseInfo = nil; + self.crashLog = nil; } return self; } From a29fa60e5e00d98dafb3f4d41256c6d228a223bf Mon Sep 17 00:00:00 2001 From: Danish Phiroz Date: Wed, 2 Oct 2024 12:47:26 -0400 Subject: [PATCH 2/3] PR Review comments fixed --- .../MVMCoreLoadRequestOperation.m | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index bebb54d..64e5bce 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -686,19 +686,18 @@ if (obj && [obj isKindOfClass:[NSDictionary class]]) { NSDictionary *responseInfo = [obj dict:KeyResponseInfo]; + //Response Info is missing but errorObject should be created with generic message + code + domain if (responseInfo == nil) { - errorObject = [[MVMCoreLoadHandler sharedGlobal] errorForLoadObject:loadObject withTitle:nil message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorCritical] code:ErrorCodeJSONNotDictionary domain:ErrorDomainSystem]; - }else { - if (![ValueTypeSuccess isEqualToString:[responseInfo string:KeyType]]) { - errorObject = [[MVMCoreLoadHandler sharedGlobal] attachLoadInformation:loadObject toError: - [[MVMCoreErrorObject alloc] - initWithTitle:[responseInfo stringForKey:KeyErrorHeading] - message:[responseInfo stringForKey:KeyUserMessage] - messageToLog:[responseInfo stringForKey:KeyMessage] - code:[[responseInfo string:KeyCode] integerValue] - domain:ErrorDomainServer - location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]]]; - } + errorObject = [[MVMCoreLoadHandler sharedGlobal] errorForLoadObject:loadObject withTitle:nil message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorCritical] code:ErrorCodeJSONNotDictionary domain:ErrorDomainServer]; + }else if (![ValueTypeSuccess isEqualToString:[responseInfo string:KeyType]]) { + errorObject = [[MVMCoreLoadHandler sharedGlobal] attachLoadInformation:loadObject toError: + [[MVMCoreErrorObject alloc] + initWithTitle:[responseInfo stringForKey:KeyErrorHeading] + message:[responseInfo stringForKey:KeyUserMessage] + messageToLog:[responseInfo stringForKey:KeyMessage] + code:[[responseInfo string:KeyCode] integerValue] + domain:ErrorDomainServer + location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]]]; } // Caches each dictionary from the array. [[MVMCoreCache sharedCache] addModuleToCache:obj module:key queue:nil waitUntilFinished:YES completionBlock:NULL]; From 4b35a8bb2d61bfc64cf7ff0117e99dd716ddf546 Mon Sep 17 00:00:00 2001 From: Danish Phiroz Date: Wed, 2 Oct 2024 13:27:33 -0400 Subject: [PATCH 3/3] PR Review comment fixed --- MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 64e5bce..0afeeba 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -689,7 +689,7 @@ //Response Info is missing but errorObject should be created with generic message + code + domain if (responseInfo == nil) { errorObject = [[MVMCoreLoadHandler sharedGlobal] errorForLoadObject:loadObject withTitle:nil message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorCritical] code:ErrorCodeJSONNotDictionary domain:ErrorDomainServer]; - }else if (![ValueTypeSuccess isEqualToString:[responseInfo string:KeyType]]) { + } else if (![ValueTypeSuccess isEqualToString:[responseInfo string:KeyType]]) { errorObject = [[MVMCoreLoadHandler sharedGlobal] attachLoadInformation:loadObject toError: [[MVMCoreErrorObject alloc] initWithTitle:[responseInfo stringForKey:KeyErrorHeading]