Prevent double logging and double error popup.

This commit is contained in:
Kyle Matthew Hedden 2023-03-13 19:45:58 -04:00
parent 6c0f0993a0
commit 289a31af24
2 changed files with 3 additions and 1 deletions

View File

@ -155,7 +155,7 @@ import MVMCore
case .decoderErrorModelNotMapped(let identifier, let codingKey, let codingPath) where identifier != nil && codingKey != nil && codingPath != nil:
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, let codingPath):
return "Error parsing template. Required model \"\(codingKey.stringValue)\" was not found @ \(codingPath.map { return $0.stringValue })"
default:
@ -475,6 +475,7 @@ import MVMCore
open func handleAction(error: Error, model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) {
let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: MVMCoreActionHandler.getErrorLocation(with: delegateObject?.actionDelegate, actionType: model.actionType))!
errorObject.silentError = (error as? MVMCoreErrorObject)?.silentError ?? false // Prefer incoming settings, then default to loud.
MVMCoreUIActionHandler.shared()?.defaultHandleActionError(errorObject, additionalData: additionalData)
}

View File

@ -41,6 +41,7 @@ import SafariServices
open override func defaultHandleActionError(_ error: MVMCoreErrorObject, additionalData: [AnyHashable : Any]?) {
super.defaultHandleActionError(error, additionalData: additionalData)
guard !error.silentError else { return }
error.silentError = true // Silence if this error is triggered again. (Legacy action handler flow.)
Task(priority: .userInitiated) { @MainActor in
let alertObject = MVMCoreAlertObject.init(popupAlertWithError: error, isGreedy: false)!
MVMCoreAlertHandler.shared()?.showAlert(with: alertObject)