b6fdee8bfc
Consolidated release: the cross-platform Linux port (engine, generators, CLI, REPL, NRT, portable DSP), live ALSA audio + ALSA MIDI + POSIX OSC + portable WAV codec, the GTK4 GUI (LyrebirdUI on the SwiftOpenUI backend), and the Linux live-coding scratchpad (LiveCompile). Apple platforms unchanged; all additive. See RELEASES.md and LINUX_README.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
59 lines
2.5 KiB
Swift
59 lines
2.5 KiB
Swift
// LiveSessionError.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// LyrebirdLiveCompile
|
|
//
|
|
// `LiveSession.compileAndRun(_:additive:)` throws this richer error so callers
|
|
// see diagnostics pre-mapped to user-snippet coordinates. Other `LiveCompileError`
|
|
// cases (toolchain missing, dlopen failure, etc.) pass through under
|
|
// `.compilerError`.
|
|
|
|
#if os(macOS) || os(Linux)
|
|
|
|
public enum LiveSessionError: Error, CustomStringConvertible, Sendable {
|
|
/// Snippet failed to compile. `diagnostics` are already line-mapped via the
|
|
/// active `SnippetHarness` offset; `underlying` is the raw `swiftc` failure
|
|
/// the diagnostics were parsed from.
|
|
case snippetCompileFailed(diagnostics: [Diagnostic], underlying: LiveCompileError)
|
|
|
|
/// Any other `LiveCompileError` case — toolchain missing, dlopen failure,
|
|
/// missing entry symbol, IO failure.
|
|
case compilerError(LiveCompileError)
|
|
|
|
/// The interpreted graph-DSL failed to lex/parse/build or its graphs were
|
|
/// rejected by the engine. `diagnostics` are already mapped to user-source
|
|
/// coordinates (a parse error resolves to a line/column; a build error has
|
|
/// `line: nil`). No swiftc is involved — this is the instant DSL path.
|
|
case graphDSLFailed(diagnostics: [Diagnostic], underlying: Error)
|
|
|
|
public var description: String {
|
|
switch self {
|
|
case .snippetCompileFailed(let diagnostics, let underlying):
|
|
if diagnostics.isEmpty {
|
|
return "snippet compile failed:\n\(underlying)"
|
|
}
|
|
let summary: String = diagnostics.map { diag -> String in
|
|
let location: String = diag.line.map { "\($0):\(diag.column)" } ?? "preamble:\(diag.rawLine):\(diag.column)"
|
|
return "\(location) \(diag.severity.rawValue): \(diag.message)"
|
|
}.joined(separator: "\n")
|
|
return "snippet compile failed:\n\(summary)"
|
|
case .compilerError(let underlying):
|
|
return "live compile error: \(underlying)"
|
|
case .graphDSLFailed(let diagnostics, let underlying):
|
|
if diagnostics.isEmpty {
|
|
return "graph DSL failed:\n\(underlying)"
|
|
}
|
|
let summary: String = diagnostics.map { diag -> String in
|
|
let location: String = diag.line.map { "\($0):\(diag.column)" } ?? "?"
|
|
return "\(location) \(diag.severity.rawValue): \(diag.message)"
|
|
}.joined(separator: "\n")
|
|
return "graph DSL failed:\n\(summary)"
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|