From db51edc9146998e37c973e0a91de3492fb48472a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 16 Jul 2018 10:38:56 -0400 Subject: [PATCH] Logs when server sends error screen with no page. Popup to catch users on splash screen when server sends bad response --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h | 1 + MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m | 2 ++ MVMCore/MVMCore/Constants/MVMCoreErrorConstants.h | 3 ++- .../LoadHandling/MVMCoreLoadRequestOperation.m | 14 ++++++++++++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h index ccaaa7f..4b9d12c 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h @@ -33,6 +33,7 @@ typedef void (^TextFieldErrorHandler)(NSArray * _Nonnull fieldErrors); @property (nonatomic) BOOL isGreedy; @property (nonatomic) UIAlertControllerStyle alertStyle; @property (nonatomic) MFAlertType type; +@property (nonatomic) BOOL defaultAction; @property (nonnull, strong, nonatomic) NSArray *fieldErrors; @property (nullable, nonatomic, copy) TextFieldErrorHandler textFieldErrorHandler; diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m index ff199a6..5599049 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m @@ -39,6 +39,7 @@ // only if actions are empty, then go inside and set OK as default action if (alert.type == MFAlertTypePopup && alert.actions.count == 0) { + alert.defaultAction = YES; alert.actions = @[[UIAlertAction actionWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedOK] style:UIAlertActionStyleDefault handler:nil]]; } return alert; @@ -119,6 +120,7 @@ self.title = error.title; self.message = [NSString stringWithFormat:@"%@ (%@)",error.messageToDisplay,[error stringErrorCode]]; self.actions = @[[UIAlertAction actionWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedOK] style:UIAlertActionStyleDefault handler:nil]]; + self.defaultAction = YES; self.isGreedy = isGreedy; self.type = MFAlertTypePopup; self.alertStyle = UIAlertControllerStyleAlert; diff --git a/MVMCore/MVMCore/Constants/MVMCoreErrorConstants.h b/MVMCore/MVMCore/Constants/MVMCoreErrorConstants.h index 0109cb9..35f5e6c 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreErrorConstants.h +++ b/MVMCore/MVMCore/Constants/MVMCoreErrorConstants.h @@ -38,5 +38,6 @@ typedef NS_ENUM(NSInteger, ErrorCode) { ErrorCodeInvalidSettingType, ErrorCodeServerFailSendFaceIDHash, ErrorCodeSSL, - ErrorCodeNoViewControllerToPresentOn + ErrorCodeNoViewControllerToPresentOn, + ErrorCodeNoErrorPageSent }; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index e989287..7c919b1 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -480,10 +480,20 @@ return; } + // Check if we should load a screen. if (loadObject.operation.backgroundLoad || (!error.errorScreenError && loadObject.requestParameters.noViewControllerToLoad) || (!error.nativeDrivenErrorScreen && loadObject.pageType.length == 0)) { - // No screen to load, finish the load. - [MVMCoreLoadRequestOperation loadFinished:loadObject loadedViewController:nil errorObject:error]; + // If the server told us there is an error screen but did not provide the page, show a critical error and log so we can have them fix it. + if (error.errorScreenError && !error.nativeDrivenErrorScreen && loadObject.pageType.length == 0) { + error.logError = YES; + error.errorScreenError = NO; + error.location = [NSString stringWithFormat:@"%li-%@",(long)ErrorCodeNoErrorPageSent,error.location]; + [MVMCoreLoadRequestOperation handleError:error loadObject:loadObject showAlertForErrorIfApplicable:YES]; + [MVMCoreLoadRequestOperation loadFinished:loadObject loadedViewController:nil errorObject:error]; + } else { + // No screen to load, finish the load. + [MVMCoreLoadRequestOperation loadFinished:loadObject loadedViewController:nil errorObject:error]; + } } else { // We have a screen to show.