diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift index 48484d9..23bb047 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift @@ -44,37 +44,32 @@ 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") } - + //get the action Handler for the actionModel created let actionHandler = try ModelRegistry.getActionHandler(actionModel) //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.