Skip to main content

gaze_proxy/
error.rs

1use std::path::PathBuf;
2
3use http::Method;
4use thiserror::Error;
5use url::Url;
6
7#[derive(Debug, Error)]
8#[non_exhaustive]
9pub enum ProxyError {
10    #[error("upstream unreachable: {url}")]
11    UpstreamUnreachable {
12        url: Url,
13        #[source]
14        source: reqwest::Error,
15    },
16    #[error("adapter not found for {method} {path}")]
17    AdapterNotFound { path: String, method: Method },
18    #[error("body too large: limit {limit_bytes} bytes")]
19    BodyTooLarge { limit_bytes: u64 },
20    #[error("invalid json body")]
21    InvalidJson {
22        #[source]
23        source: serde_json::Error,
24    },
25    #[error("sse partial frame: {reason}")]
26    SsePartialFrame { reason: String },
27    #[error("pipeline failed")]
28    Pipeline {
29        #[source]
30        source: gaze::Error,
31    },
32    #[error("http server failed")]
33    Server {
34        #[source]
35        source: std::io::Error,
36    },
37    #[error("daemon already running: pid {pid} ({pidfile})", pidfile = pidfile.display())]
38    DaemonAlreadyRunning { pid: u32, pidfile: PathBuf },
39    #[error("daemon is not running")]
40    DaemonNotRunning,
41    #[error("daemon pidfile stale: {pidfile}", pidfile = pidfile.display())]
42    DaemonPidfileStale { pidfile: PathBuf },
43    #[error("daemon io failed: {path}", path = path.display())]
44    DaemonIo {
45        path: PathBuf,
46        #[source]
47        source: std::io::Error,
48    },
49    #[error("daemon config failed: {detail}")]
50    DaemonConfig { detail: String },
51}