From 8f2369b7d8a09822450cc84ef6ed7bdb4c4dcf7b Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Wed, 4 Dec 2024 15:23:43 +1100 Subject: [PATCH] ignoreMissingProperties is a better name than ignoreUnknownProperties --- Sources/SwiftOCADevice/OCC/ControlClasses/Root.swift | 8 ++++++-- .../SwiftOCADevice/OCC/PropertyTypes/Serialization.swift | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Sources/SwiftOCADevice/OCC/ControlClasses/Root.swift b/Sources/SwiftOCADevice/OCC/ControlClasses/Root.swift index f42b73e..0dd3efc 100644 --- a/Sources/SwiftOCADevice/OCC/ControlClasses/Root.swift +++ b/Sources/SwiftOCADevice/OCC/ControlClasses/Root.swift @@ -391,8 +391,12 @@ open class OcaRoot: CustomStringConvertible, Codable, Sendable, OcaKeyPathMarker let propertyName = property.propertyID.description guard let value = jsonObject[propertyName] else { - if flags.contains(.ignoreUnknownProperties) { continue } - else { throw Ocp1Error.status(.parameterOutOfRange) } + if flags.contains(.ignoreMissingProperties) { + continue + } else { + logger.warning("JSON object \(jsonObject) is missing \(propertyName)") + throw Ocp1Error.status(.parameterOutOfRange) + } } do { diff --git a/Sources/SwiftOCADevice/OCC/PropertyTypes/Serialization.swift b/Sources/SwiftOCADevice/OCC/PropertyTypes/Serialization.swift index 7eb9ce3..731d9a5 100644 --- a/Sources/SwiftOCADevice/OCC/PropertyTypes/Serialization.swift +++ b/Sources/SwiftOCADevice/OCC/PropertyTypes/Serialization.swift @@ -55,13 +55,13 @@ public extension OcaRoot { } public static let ignoreDecodingErrors = DeserializationFlags(rawValue: 1 << 0) - public static let ignoreUnknownProperties = DeserializationFlags(rawValue: 1 << 1) + public static let ignoreMissingProperties = DeserializationFlags(rawValue: 1 << 1) public static let ignoreUnknownObjectNumbers = DeserializationFlags(rawValue: 1 << 2) public static let ignoreObjectClassMismatches = DeserializationFlags(rawValue: 1 << 3) public static let ignoreAllErrors: DeserializationFlags = [ .ignoreDecodingErrors, - .ignoreUnknownProperties, + .ignoreMissingProperties, .ignoreUnknownObjectNumbers, .ignoreObjectClassMismatches, ]