razeri_plugin_api/
error.rs1use thiserror::Error;
6
7#[derive(Debug, Error)]
9#[non_exhaustive]
10pub enum StorageError {
11 #[error("storage configuration error: {0}")]
13 ConfigError(String),
14 #[error("storage I/O error: {0}")]
16 IoError(String),
17 #[error("storage provider not found: {0}")]
19 ProviderNotFound(String),
20}
21
22#[derive(Debug, Error)]
24#[non_exhaustive]
25pub enum LlmError {
26 #[error("HTTP error: {0}")]
28 HttpError(String),
29 #[error("JSON parse error: {0}")]
31 JsonError(String),
32 #[error("provider error (status {status}): {message}")]
34 ProviderError {
35 status: u16,
37 message: String,
39 },
40 #[error("unsupported provider: {0}")]
42 UnsupportedProvider(String),
43 #[error("missing API key for provider: {0}")]
45 MissingApiKey(String),
46 #[error("unexpected response format: {0}")]
48 UnexpectedFormat(String),
49}
50
51impl LlmError {
52 #[must_use]
55 pub fn is_transient(&self) -> bool {
56 match self {
57 LlmError::HttpError(_) => true,
58 LlmError::ProviderError { status, .. } => matches!(status, 429 | 502 | 503 | 504),
59 _ => false,
60 }
61 }
62}
63
64#[derive(Debug, Error)]
66#[non_exhaustive]
67pub enum EventSinkError {
68 #[error("event sink error: {0}")]
70 SinkError(String),
71 #[error("event sink connection failed: {0}")]
73 ConnectionFailed(String),
74}
75
76#[derive(Debug, Error)]
78#[non_exhaustive]
79pub enum LanguageError {
80 #[error("language rendering error: {0}")]
82 RenderError(String),
83 #[error("unsupported language feature: {0}")]
85 UnsupportedFeature(String),
86}