Skip to main content

mini_chat_sdk/
error.rs

1use thiserror::Error;
2
3/// Errors returned by `MiniChatModelPolicyPluginClientV1` methods.
4#[derive(Debug, Error)]
5pub enum MiniChatModelPolicyPluginError {
6    #[error("policy not found for the given tenant/version")]
7    NotFound,
8
9    #[error("internal policy plugin error: {0}")]
10    Internal(String),
11}
12
13/// Errors returned by `publish_usage()`.
14#[derive(Debug, Error)]
15pub enum PublishError {
16    /// Transient failure — safe to retry.
17    #[error("transient publish error: {0}")]
18    Transient(String),
19
20    /// Permanent failure — do not retry.
21    #[error("permanent publish error: {0}")]
22    Permanent(String),
23}
24
25impl PublishError {
26    #[must_use]
27    pub fn is_transient(&self) -> bool {
28        matches!(self, Self::Transient(_))
29    }
30
31    #[must_use]
32    pub fn is_permanent(&self) -> bool {
33        matches!(self, Self::Permanent(_))
34    }
35}