diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index 9644557..26afbe2 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -93,6 +93,9 @@ extern NSString * _Nonnull const KeyActionTypeOpen; #pragma mark - Default Action Protocol Functions +// Currently no default log action but this will eventually be server driven. ++ (void)defaultLogAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; + // Sends the request to the load handler. + (void)defaultHandleOpenPageForRequestParameters:(nonnull MVMCoreRequestParameters *)requestParameters additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index b4a79eb..1fa736a 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -110,7 +110,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; if ([delegateObject.actionDelegate respondsToSelector:@selector(logActionWithActionInformation:additionalData:)]) { [delegateObject.actionDelegate logActionWithActionInformation:actionInformation additionalData:additionalData]; } else { - [MVMCoreActionHandler defaultLogAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + [[self class] defaultLogAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; } } diff --git a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift index f9ec58b..93407d1 100644 --- a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift +++ b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift @@ -16,8 +16,8 @@ public struct ModelRegistry { case encoderError case decoderError case decoderOther(message: String) - case decoderErrorObjectNotPresent - case decoderErrorModelNotMapped + case decoderErrorObjectNotPresent(codingKey: CodingKey, codingPath: [CodingKey]) + case decoderErrorModelNotMapped(identifer: String? = nil, codingKey: CodingKey? = nil, codingPath: [CodingKey]? = nil) case other(message: String) } @@ -75,8 +75,8 @@ extension KeyedDecodingContainer where Key: CodingKey { /// Decodes to a registered model based on the identifier public func decodeModel(codingKey: KeyedDecodingContainer.Key) throws -> T { guard let model: T = try decodeModelIfPresent(codingKey: codingKey) else { - MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey)") - throw ModelRegistry.Error.decoderErrorObjectNotPresent + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey.stringValue)") + throw ModelRegistry.Error.decoderErrorObjectNotPresent(codingKey: codingKey, codingPath: codingPath) } return model } @@ -84,8 +84,8 @@ extension KeyedDecodingContainer where Key: CodingKey { /// Decodes an array of registered model based on the identifiers. public func decodeModels(codingKey: KeyedDecodingContainer.Key) throws -> [T] { guard let model: [T] = try decodeModelsIfPresent(codingKey: codingKey) else { - MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey)") - throw ModelRegistry.Error.decoderErrorObjectNotPresent + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey.stringValue)") + throw ModelRegistry.Error.decoderErrorObjectNotPresent(codingKey: codingKey, codingPath: codingPath) } return model } @@ -93,8 +93,8 @@ extension KeyedDecodingContainer where Key: CodingKey { /// Decodes an array with arrays of models based on the identifiers. public func decodeModels2D(codingKey: KeyedDecodingContainer.Key) throws -> [[T]] { guard let models: [[T]] = try decodeModels2DIfPresent(codingKey: codingKey) else { - MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey)") - throw ModelRegistry.Error.decoderErrorObjectNotPresent + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey.stringValue)") + throw ModelRegistry.Error.decoderErrorObjectNotPresent(codingKey: codingKey, codingPath: codingPath) } return models } @@ -114,7 +114,7 @@ extension KeyedDecodingContainer where Key: CodingKey { //get the type from the identifier value in the Registry guard let type = ModelRegistry.getType(for: identifier, with: T.self) else { MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelProtocol not mapped: \(identifier)") - throw ModelRegistry.Error.decoderErrorModelNotMapped + throw ModelRegistry.Error.decoderErrorModelNotMapped(identifer: identifier, codingKey: typeCodingKey, codingPath: container.codingPath) } //decode the type using the decoder @@ -208,7 +208,7 @@ public extension UnkeyedDecodingContainer { let identifier = try nestedContainer.decode(String.self, forKey: typeCodingKey) guard let type = ModelRegistry.getType(for: identifier, with: T.self) else { MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorModelNotMapped: \(identifier)") - throw ModelRegistry.Error.decoderErrorModelNotMapped + throw ModelRegistry.Error.decoderErrorModelNotMapped(identifer: identifier, codingKey: typeCodingKey, codingPath: nestedContainer.codingPath) } // Now get the decoder to use for the type let decoder = try self.superDecoder() @@ -233,7 +233,7 @@ public extension UnkeyedDecodingContainer { var arraycontainerCopy = try containerCopy.nestedUnkeyedContainer() guard let models: [T] = try arraycontainerCopy.decodeModelsIfPresent() else { MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorModelNotMapped: \(typeCodingKey)") - throw ModelRegistry.Error.decoderErrorModelNotMapped + throw ModelRegistry.Error.decoderErrorModelNotMapped(identifer: typeCodingKey.stringValue, codingKey: typeCodingKey, codingPath: arraycontainerCopy.codingPath) } modelLists.append(models) }