diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m index e5eb99d..8058ca5 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m @@ -104,7 +104,13 @@ } - (nonnull MVMCoreErrorObject *)attachLoadInformation:(MVMCoreLoadObject *)loadObject toError:(MVMCoreErrorObject *)error { - return error; // For now, just exposed for overriding. + // Native and system errors have an error screen. + if (![error.domain isEqualToString:ErrorDomainServer] && [[MVMCoreObject sharedInstance].globalLoadDelegate respondsToSelector:@selector(getNativeScreenForRequestError:requestObject:)]) { + error.errorScreenError = YES; + error.nativeDrivenErrorScreen = YES; + error.silentError = NO; + } + return error; } - (nonnull NSString *)errorLocationForRequest:(nonnull MVMCoreLoadObject *)loadObject { diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index e48c6dc..680ce37 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -297,6 +297,7 @@ } else { // Error with the request/response + [[MVMCoreLoadHandler sharedGlobal] attachLoadInformation:loadObject toError:error]; [MVMCoreLoadRequestOperation loadAbortedWithError:error loadObject:loadObject]; } }]; @@ -521,8 +522,12 @@ // Display or finish if (error.errorScreenError || !loadObject.requestParameters.dontDisplayViewController) { + error.silentError = NO; + [MVMCoreLoggingHandler addErrorToLog:error]; [MVMCoreLoadRequestOperation displayViewController:viewController loadObject:loadObject error:error]; } else { + error.silentError = YES; + [MVMCoreLoggingHandler addErrorToLog:error]; [MVMCoreLoadRequestOperation loadFinished:loadObject loadedViewController:viewController errorObject:error]; } } else if (!loadObject.requestParameters.shouldNotGoToServerOnCacheFail && (loadObject.pageDataFromCache || loadObject.moduleDataFromCache)) { @@ -534,7 +539,8 @@ loadObject.operation.errorForAlertToShow = nil; [loadObject.operation main]; } else { - + error.silentError = YES; + [MVMCoreLoggingHandler addErrorToLog:error]; // Otherwise the request is finished. [MVMCoreLoadRequestOperation loadFinished:loadObject loadedViewController:nil errorObject:error]; } @@ -759,11 +765,11 @@ // Show alert for error. [MVMCoreLoadRequestOperation createAndShowAlertForLoadObject:loadObject error:error delegateObject:loadObject.operation.delegateObject]; } else { - error.silentError = YES; + error.silentError = !error.errorScreenError && !error.nativeDrivenErrorScreen; } - // Logs the error. - if (error.logError) { + // Logs the error. If its a native driven error screen postpone until the native screen is define with its messaging. + if (error.logError && !error.nativeDrivenErrorScreen) { [MVMCoreLoggingHandler addErrorToLog:error]; } } diff --git a/MVMCore/MVMCore/Utility/MVMCoreErrorObject.m b/MVMCore/MVMCore/Utility/MVMCoreErrorObject.m index 40432d0..2199023 100644 --- a/MVMCore/MVMCore/Utility/MVMCoreErrorObject.m +++ b/MVMCore/MVMCore/Utility/MVMCoreErrorObject.m @@ -28,18 +28,11 @@ self.domain = domain; self.location = location; self.date = [NSDate date]; - self.silentError = YES; // TODO: Hold on this. Messes with server errors. + self.silentError = YES; self.logError = YES; [MVMCoreDispatchUtility performSyncBlockOnMainThread:^{ self.applicationState = [UIApplication sharedApplication].applicationState; }]; - - // Native and system errors have an error screen. - if (![domain isEqualToString:ErrorDomainServer] && [[MVMCoreObject sharedInstance].globalLoadDelegate respondsToSelector:@selector(getNativeScreenForRequestError:requestObject:)]) { - self.errorScreenError = YES; - self.nativeDrivenErrorScreen = YES; - self.silentError = NO; - } } return self; } @@ -54,18 +47,11 @@ self.domain = domain; self.location = location; self.date = [NSDate date]; - self.silentError = YES; // TODO: Hold on this. Messes with server errors. + self.silentError = YES; self.logError = YES; [MVMCoreDispatchUtility performSyncBlockOnMainThread:^{ self.applicationState = [UIApplication sharedApplication].applicationState; }]; - - // Native and system errors have an error screen. - if (![domain isEqualToString:ErrorDomainServer] && [[MVMCoreObject sharedInstance].globalLoadDelegate respondsToSelector:@selector(getNativeScreenForRequestError:requestObject:)]) { - self.errorScreenError = YES; - self.nativeDrivenErrorScreen = YES; - self.silentError = NO; - } } return self; } @@ -104,13 +90,9 @@ if (errorObject) { return errorObject; } - errorObject = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[error localizedDescription] messageToLog:[error description] code:[error code] domain:ErrorDomainSystem location:location]; + errorObject = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[error localizedDescription] messageToLog:[error localizedFailureReason] ?: [error localizedDescription] code:[error code] domain:ErrorDomainSystem location:location]; if ([error.domain isEqualToString:NSURLErrorDomain]) { errorObject.systemDomain = error.domain; - if ([[MVMCoreObject sharedInstance].globalLoadDelegate respondsToSelector:@selector(getNativeScreenForRequestError:requestObject:)]) { - errorObject.errorScreenError = YES; - errorObject.nativeDrivenErrorScreen = YES; - } } return errorObject; }