Skip to content

Commit

Permalink
ignoreMissingProperties is a better name than ignoreUnknownProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoward committed Dec 4, 2024
1 parent 1c7c4bb commit 8f2369b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Sources/SwiftOCADevice/OCC/ControlClasses/Root.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftOCADevice/OCC/PropertyTypes/Serialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
Expand Down

0 comments on commit 8f2369b

Please sign in to comment.