razeri_plugin_api/
error.rs1use thiserror::Error;
8
9#[derive(Debug, Error)]
11#[non_exhaustive]
12pub enum StorageError {
13 #[error("storage configuration error: {0}")]
15 ConfigError(String),
16 #[error("storage I/O error: {0}")]
18 IoError(String),
19 #[error("storage provider not found: {0}")]
21 ProviderNotFound(String),
22}
23
24#[derive(Debug, Error)]
26#[non_exhaustive]
27pub enum LlmError {
28 #[error("HTTP error: {0}")]
30 HttpError(String),
31 #[error("JSON parse error: {0}")]
33 JsonError(String),
34 #[error("provider error (status {status}): {message}")]
36 ProviderError {
37 status: u16,
39 message: String,
41 },
42 #[error("unsupported provider: {0}")]
44 UnsupportedProvider(String),
45 #[error("missing API key for provider: {0}")]
47 MissingApiKey(String),
48 #[error("unexpected response format: {0}")]
50 UnexpectedFormat(String),
51}
52
53impl LlmError {
54 #[must_use]
57 pub fn is_transient(&self) -> bool {
58 match self {
59 LlmError::HttpError(_) => true,
60 LlmError::ProviderError { status, .. } => matches!(status, 429 | 502 | 503 | 504),
61 _ => false,
62 }
63 }
64}
65
66#[derive(Debug, Error)]
68#[non_exhaustive]
69pub enum EventSinkError {
70 #[error("event sink error: {0}")]
72 SinkError(String),
73 #[error("event sink connection failed: {0}")]
75 ConnectionFailed(String),
76}
77
78#[derive(Debug, Error)]
80#[non_exhaustive]
81pub enum LanguageError {
82 #[error("language rendering error: {0}")]
84 RenderError(String),
85 #[error("unsupported language feature: {0}")]
87 UnsupportedFeature(String),
88}