Skip to main content

opencode/
error.rs

1use std::{path::PathBuf, process::ExitStatus, time::Duration};
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum OpencodeError {
7    #[error("opencode binary not found")]
8    MissingBinary,
9    #[error("failed to spawn opencode process (binary={binary:?}): {source}")]
10    Spawn {
11        binary: PathBuf,
12        source: std::io::Error,
13    },
14    #[error("opencode process timed out after {timeout:?}")]
15    Timeout { timeout: Duration },
16    #[error("failed waiting for opencode process: {0}")]
17    Wait(std::io::Error),
18    #[error("failed reading stdout: {0}")]
19    StdoutRead(std::io::Error),
20    #[error("failed reading stderr: {0}")]
21    StderrRead(std::io::Error),
22    #[error("internal error: missing stdout pipe")]
23    MissingStdout,
24    #[error("internal error: join failure: {0}")]
25    Join(String),
26    #[error("request is invalid: {0}")]
27    InvalidRequest(String),
28    #[error("{message}")]
29    SelectionFailed { message: String },
30    #[error("{message}")]
31    RunFailed { status: ExitStatus, message: String },
32}