1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright (C) 2026 Gabriel Shea
// Licensed under either of the Apache License, Version 2.0 or the MIT
// license, at your option.
//! Error types for Razeri plugin API.
use thiserror::Error;
/// Errors from storage provider operations.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum StorageError {
/// Storage configuration is missing or invalid.
#[error("storage configuration error: {0}")]
ConfigError(String),
/// An I/O error occurred during a storage operation.
#[error("storage I/O error: {0}")]
IoError(String),
/// The requested storage provider is not registered.
#[error("storage provider not found: {0}")]
ProviderNotFound(String),
}
/// Errors from LLM client operations.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum LlmError {
/// An HTTP transport error occurred.
#[error("HTTP error: {0}")]
HttpError(String),
/// The response body could not be parsed as JSON.
#[error("JSON parse error: {0}")]
JsonError(String),
/// The provider returned a non-success HTTP status.
#[error("provider error (status {status}): {message}")]
ProviderError {
/// HTTP status code returned by the provider.
status: u16,
/// Error message from the provider.
message: String,
},
/// The requested LLM provider is not registered.
#[error("unsupported provider: {0}")]
UnsupportedProvider(String),
/// An API key is required but was not configured.
#[error("missing API key for provider: {0}")]
MissingApiKey(String),
/// The response format did not match the expected schema.
#[error("unexpected response format: {0}")]
UnexpectedFormat(String),
}
impl LlmError {
/// Returns `true` for errors that may succeed on retry (connection drops,
/// server overload, etc.).
#[must_use]
pub fn is_transient(&self) -> bool {
match self {
LlmError::HttpError(_) => true,
LlmError::ProviderError { status, .. } => matches!(status, 429 | 502 | 503 | 504),
_ => false,
}
}
}
/// Errors from event sink operations.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum EventSinkError {
/// A generic event sink error.
#[error("event sink error: {0}")]
SinkError(String),
/// The event sink could not connect to its backend.
#[error("event sink connection failed: {0}")]
ConnectionFailed(String),
}
/// Errors from language renderer operations.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum LanguageError {
/// A rendering error occurred for the target language.
#[error("language rendering error: {0}")]
RenderError(String),
/// The requested language feature is not supported by this renderer.
#[error("unsupported language feature: {0}")]
UnsupportedFeature(String),
}