Crash fix for missing UserMessage. Suppress alertToShow dialogs when a native error screen is present. Pipe template parsing description messages to error object. Provide a messageToLog for invalid openURL calls.
This commit is contained in:
parent
ee7e180684
commit
6c0f0993a0
@ -132,9 +132,9 @@ import MVMCore
|
|||||||
try parsePageJSON()
|
try parsePageJSON()
|
||||||
} catch let parsingError {
|
} catch let parsingError {
|
||||||
// Log all parsing errors and fail load.
|
// Log all parsing errors and fail load.
|
||||||
handleLoggingFor(parsingError: parsingError)
|
|
||||||
if let errorObject = MVMCoreLoadHandler.sharedGlobal()?.error(for: loadObject, causedBy: parsingError) {
|
if let errorObject = MVMCoreLoadHandler.sharedGlobal()?.error(for: loadObject, causedBy: parsingError) {
|
||||||
errorObject.messageToDisplay = MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess)
|
errorObject.messageToDisplay = MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess)
|
||||||
|
errorObject.messageToLog = describe(parsingError: parsingError)
|
||||||
error.pointee = errorObject
|
error.pointee = errorObject
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@ -149,37 +149,38 @@ import MVMCore
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleLoggingFor(parsingError: Error) {
|
func describe(parsingError: Error) -> String {
|
||||||
if let registryError = parsingError as? ModelRegistry.Error {
|
if let registryError = parsingError as? ModelRegistry.Error {
|
||||||
switch (registryError) {
|
switch (registryError) {
|
||||||
case .decoderErrorModelNotMapped(let identifier, let codingKey, let codingPath) where identifier != nil && codingKey != nil && codingPath != nil:
|
case .decoderErrorModelNotMapped(let identifier, let codingKey, let codingPath) where identifier != nil && codingKey != nil && codingPath != nil:
|
||||||
MVMCoreLoggingHandler.shared()?.handleDebugMessage("Error parsing template: Model identifier \"\(identifier!)\" is not mapped for \"\(codingKey!.stringValue)\" @ \(codingPath!.map { return $0.stringValue })")
|
return "Error parsing template. Model identifier \"\(identifier!)\" is not mapped for \"\(codingKey!.stringValue)\" @ \(codingPath!.map { return $0.stringValue })"
|
||||||
|
|
||||||
case .decoderErrorObjectNotPresent(let codingKey, codingPath: let codingPath):
|
case .decoderErrorObjectNotPresent(let codingKey, codingPath: let codingPath):
|
||||||
MVMCoreLoggingHandler.shared()?.handleDebugMessage("Error parsing template: Required model \"\(codingKey.stringValue)\" was not found @ \(codingPath.map { return $0.stringValue })")
|
return "Error parsing template. Required model \"\(codingKey.stringValue)\" was not found @ \(codingPath.map { return $0.stringValue })"
|
||||||
|
|
||||||
default:
|
default:
|
||||||
MVMCoreLoggingHandler.shared()?.handleDebugMessage("Error parsing template: Registry error: \(registryError)")
|
return "Error parsing template. Registry error: \((registryError as NSError).localizedFailureReason ?? registryError.localizedDescription)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let decodingError = parsingError as? DecodingError {
|
if let decodingError = parsingError as? DecodingError {
|
||||||
switch (decodingError) {
|
switch (decodingError) {
|
||||||
case .keyNotFound(let codingKey, let context):
|
case .keyNotFound(let codingKey, let context):
|
||||||
MVMCoreLoggingHandler.shared()?.handleDebugMessage("Error parsing template: Key \(codingKey.stringValue) was not found @ \(context.codingPath.map { return $0.stringValue })")
|
return "Error parsing template. Key \(codingKey.stringValue) was not found @ \(context.codingPath.map { return $0.stringValue })"
|
||||||
|
|
||||||
case .valueNotFound(_, let context):
|
case .valueNotFound(_, let context):
|
||||||
MVMCoreLoggingHandler.shared()?.handleDebugMessage("Error parsing template: Value not found @ \(context.codingPath.map { return $0.stringValue })")
|
return "Error parsing template. Value not found @ \(context.codingPath.map { return $0.stringValue })"
|
||||||
|
|
||||||
case .typeMismatch(_, let context):
|
case .typeMismatch(_, let context):
|
||||||
MVMCoreLoggingHandler.shared()?.handleDebugMessage("Error parsing template: Type mismatch @ \(context.codingPath.map { return $0.stringValue })")
|
return "Error parsing template. Type mismatch @ \(context.codingPath.map { return $0.stringValue })"
|
||||||
|
|
||||||
case .dataCorrupted(let context):
|
case .dataCorrupted(let context):
|
||||||
MVMCoreLoggingHandler.shared()?.handleDebugMessage("Error parsing template: Data corrupted @ \(context.codingPath.map { return $0.stringValue })")
|
return "Error parsing template. Data corrupted @ \(context.codingPath.map { return $0.stringValue })"
|
||||||
|
|
||||||
@unknown default:
|
@unknown default:
|
||||||
MVMCoreLoggingHandler.shared()?.handleDebugMessage("Error parsing template: \(parsingError)")
|
return "Error parsing template. \((parsingError as NSError).localizedFailureReason ?? parsingError.localizedDescription)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return "Error parsing template. \((parsingError as NSError).localizedFailureReason ?? parsingError.localizedDescription)"
|
||||||
}
|
}
|
||||||
|
|
||||||
open func parsePageJSON() throws { }
|
open func parsePageJSON() throws { }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user