Files
Lyrebird/Sources/Lyrebird/Engine/EngineHostError.swift
T
2026-06-01 18:27:40 -07:00

49 lines
2.0 KiB
Swift

// EngineHostError.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import Foundation
/// Errors thrown from `EngineHost` API.
public enum EngineHostError: Error, CustomStringConvertible {
/// Two registrations attempted under the same `EngineHostRole`.
/// Use a distinct role (e.g. bump the `nrtRender(slot:)` index, or
/// promote to `.custom(String)`).
case duplicateRole(EngineHostRole)
// The `.duplicateDevice(UInt32)` case was removed.
// `.rtOutput(deviceID:)` carries the deviceID inside the role's
// Hashable key, so same-device registration surfaces as
// `.duplicateRole`. The dedicated case had no producer in current
// code and forced every exhaustive consumer switch to handle dead
// code. Re-add if a future role shape ever cross-cuts deviceID
// under a different surrounding enum case.
/// `host.startAll()` encountered an underlying `engine.start()`
/// failure on one of the registered engines. The error chain
/// includes the failing engine's identifier and the wrapped
/// underlying error.
case startFailed(engine: UUID, underlying: any Error)
/// `host.adopt(existing:)` rejected an engine because its
/// `EngineLifecycleCoordinator` registration cannot be assumed
/// (the engine has already deinited or was constructed via a path
/// the host cannot verify).
case adoptRejected(engine: UUID, reason: String)
public var description: String {
switch self {
case .duplicateRole(let role):
return "EngineHost: duplicate registration for role \(role). " +
"Use a distinct role identifier."
case .startFailed(let engine, let underlying):
return "EngineHost: startAll() failed at engine \(engine): \(underlying)"
case .adoptRejected(let engine, let reason):
return "EngineHost: adopt(existing:) rejected engine \(engine): \(reason)"
}
}
}