Type casting failed error fixed.
This commit is contained in:
parent
3e1581e28e
commit
9dde688feb
@ -365,11 +365,26 @@ public extension UnkeyedDecodingContainer {
|
|||||||
}
|
}
|
||||||
// Now get the decoder to use for the type
|
// Now get the decoder to use for the type
|
||||||
let decoder = try self.superDecoder()
|
let decoder = try self.superDecoder()
|
||||||
if let model = try type.init(from: decoder) as? T {
|
let model = try type.init(from: decoder)
|
||||||
|
|
||||||
|
if let model = model as? T {
|
||||||
models.append(model)
|
models.append(model)
|
||||||
} else {
|
} else {
|
||||||
MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderError: \(typeCodingKey)")
|
let typeName = "\(T.self)".components(separatedBy: "&").last?.trimmingCharacters(in: .whitespaces) ?? "\(T.self)"
|
||||||
throw ModelRegistry.Error.decoderError
|
let mirror = Mirror(reflecting: model)
|
||||||
|
|
||||||
|
let logMessage = """
|
||||||
|
ModelRegistry Error:
|
||||||
|
Model Type Casting Failed:
|
||||||
|
- Attempted to cast value of type '\(mirror.subjectType)' to '\(typeName)'.
|
||||||
|
- Molecule Identifier: '\(identifier)'
|
||||||
|
- Debug Context:
|
||||||
|
Actual Type: '\(mirror.subjectType)'
|
||||||
|
Expected Type: '\(typeName)'
|
||||||
|
"""
|
||||||
|
|
||||||
|
MVMCoreLoggingHandler.logDebugMessage(withDelegate: logMessage)
|
||||||
|
throw ModelRegistry.Error.decoderErrorModelNotMapped(identifer: identifier, codingKey: typeCodingKey, codingPath: nestedContainer.codingPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user