fix for legacy

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2021-10-22 15:05:24 -05:00
parent 6c8bb9ce4b
commit 59ff7d2fad

View File

@ -44,14 +44,12 @@ public extension MVMCoreActionHandler {
@objc func hasActionHandler(actionType: String?, actionInformation: [String: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) -> Bool {
//ensure there is a Serialized version of the Action
guard let actionType = actionType, let actionInformation = actionInformation else { return false }
guard let actionType = actionType,
let actionInformation = actionInformation,
let actionModelType = ModelRegistry.getType(for: actionType, with: ActionModelProtocol.self)
else { return false }
do {
//get the actionModelType
guard let actionModelType = ModelRegistry.getType(for: actionType, with: ActionModelProtocol.self) else {
throw ModelRegistry.Error.decoderErrorModelNotMapped()
}
//deserialize the actionModel for the actionType found
guard let actionModel = try actionModelType.decode(jsonDict: actionInformation) as? ActionModelProtocol else {
throw ModelRegistry.Error.decoderOther(message: "Could not decode to ActionModelProtocol")
@ -63,18 +61,15 @@ public extension MVMCoreActionHandler {
//call the handleAction of the handler
actionHandler.handleAction(actionModel, additionalData: additionalData, delegateObject: delegateObject)
//complete
return true
} catch {
//log the error
if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "") {
MVMCoreActionHandler.shared()?.defaultHandleActionError(errorObject, additionalData: additionalData)
}
//incomplete
return false
}
//complete
return true
}
/// Start action on current thread.