// LiveCompileError.swift // Lyrebird // // Copyright (c) 2026 Joshua Parmenter / realizedsound // SPDX-License-Identifier: MIT // LyrebirdLiveCompile — core // // Errors raised by `LiveCompiler.compile(source:)`. RT path never sees these: // compilation is a main-thread (or background-queue) operation that runs long // before any audio block. import Foundation #if os(macOS) public enum LiveCompileError: Error, CustomStringConvertible, Equatable, Sendable { /// `xcrun -f swiftc` and the fallback paths all failed. case swiftcNotFound /// `swiftc` exited non-zero. `stderr` carries the raw compiler output; Phase /// 144 parses it into structured diagnostics. case compileFailed(exitCode: Int32, stderr: String) /// `dlopen(dylibPath, RTLD_NOW)` returned `nil`. `message` is the `dlerror()` /// string at the time of the failure. case dlopenFailed(path: String, message: String) /// The dylib opened but did not export the expected entry symbol. case entrySymbolMissing(symbol: String, message: String) /// A temp-dir / write step failed before `swiftc` was invoked. case ioFailed(underlying: String) public var description: String { switch self { case .swiftcNotFound: return "swiftc binary not found in xcrun or standard toolchain paths" case .compileFailed(let code, let stderr): return "swiftc exited \(code):\n\(stderr)" case .dlopenFailed(let path, let message): return "dlopen failed for \(path): \(message)" case .entrySymbolMissing(let symbol, let message): return "missing snippet entry symbol \(symbol): \(message)" case .ioFailed(let underlying): return "IO step failed: \(underlying)" } } } #endif