Skip to content

Commit

Permalink
replace notImplemented with MOMPanel.CommandNotHandled
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoward committed Jul 31, 2023
1 parent b29f99d commit aa7945e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Sources/MOMOCABridge/ControlClasses/MOMButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class MOMButton: SwiftOCADevice.OcaBooleanActuator, MOMKeyProtocol {
) async throws -> Ocp1Response {
do {
return try await handleCommonMomCommand(command, from: controller)
} catch Ocp1Error.status(.notImplemented) {
} catch is MOMPanel.CommandNotHandled {
switch command.methodID {
case OcaMethodID("2.8"):
guard let bridge else { throw Ocp1Error.status(.deviceError) }
Expand Down
2 changes: 1 addition & 1 deletion Sources/MOMOCABridge/ControlClasses/MOMExternalKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MOMExternalKey: SwiftOCADevice.OcaBooleanActuator, MOMKeyProtocol {
) async throws -> Ocp1Response {
do {
return try await handleCommonMomCommand(command, from: controller)
} catch Ocp1Error.status(.notImplemented) {
} catch is MOMPanel.CommandNotHandled {
switch command.methodID {
case OcaMethodID("2.8"):
guard let bridge else { throw Ocp1Error.status(.deviceError) }
Expand Down
2 changes: 1 addition & 1 deletion Sources/MOMOCABridge/ControlClasses/MOMGainControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MOMSteppedGainControl: SwiftOCADevice.OcaGain, MOMPanelControl {
) async throws -> Ocp1Response {
do {
return try await handleCommonMomCommand(command, from: controller)
} catch Ocp1Error.status(.notImplemented) {
} catch is MOMPanel.CommandNotHandled {
switch command.methodID {
case OcaMethodID("4.2"):
try await ensureWritableAndConnectedToDadMan(controller)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MOMIdentificationSensor: SwiftOCADevice.OcaIdentificationSensor, MOMPanelC
) async throws -> Ocp1Response {
do {
return try await handleCommonMomCommand(command, from: controller)
} catch Ocp1Error.status(.notImplemented) {
} catch is MOMPanel.CommandNotHandled {
return try await super.handleCommand(command, from: controller)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MOMLayerIndicator: SwiftOCADevice.OcaUint8Sensor, MOMPanelControl {
) async throws -> Ocp1Response {
do {
return try await handleCommonMomCommand(command, from: controller)
} catch Ocp1Error.status(.notImplemented) {
} catch is MOMPanel.CommandNotHandled {
return try await super.handleCommand(command, from: controller)
}
}
Expand Down
6 changes: 4 additions & 2 deletions Sources/MOMOCABridge/ControlClasses/MOMPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extension MOMPanelControl {
try await ensureWritable(by: controller)
fallthrough
default:
throw Ocp1Error.notImplemented
throw MOMPanel.CommandNotHandled()
}
}

Expand Down Expand Up @@ -82,6 +82,8 @@ class MOMPanel: SwiftOCADevice.OcaBlock<SwiftOCADevice.OcaWorker>, MOMPanelContr
var layer: MOMLayerIndicator
var identificationSensor: MOMIdentificationSensor

struct CommandNotHandled: Error {}

init(bridge: MOMOCABridge) async throws {
self.bridge = bridge

Expand All @@ -108,7 +110,7 @@ class MOMPanel: SwiftOCADevice.OcaBlock<SwiftOCADevice.OcaWorker>, MOMPanelContr
) async throws -> Ocp1Response {
do {
return try await handleCommonMomCommand(command, from: controller)
} catch Ocp1Error.status(.notImplemented) {
} catch is MOMPanel.CommandNotHandled {
return try await super.handleCommand(command, from: controller)
}
}
Expand Down

0 comments on commit aa7945e

Please sign in to comment.