pub enum Error {
Show 13 variants
Scanner {
scanner: String,
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Model(String),
Config(String),
InvalidInput(String),
Io(Error),
Serialization(Error),
Vault(String),
Timeout(u64),
ResourceExhausted(String),
Internal(String),
Auth(String),
Unauthorized(String),
NotFound(String),
}Expand description
Core error type for LLM Shield operations
§Design Principles
- Specific Variants: Each error type has a specific variant
- Context: All errors include contextual information
- Source Chaining: Errors properly chain their sources
- Display: Human-readable error messages
Variants§
Scanner
Scanner-specific errors
Model(String)
Model loading or inference errors
Config(String)
Configuration errors
InvalidInput(String)
Invalid input data
Io(Error)
I/O errors
Serialization(Error)
Serialization errors
Vault(String)
Vault errors (state management)
Timeout(u64)
Timeout errors
ResourceExhausted(String)
Resource exhaustion
Internal(String)
Internal errors (should not happen in production)
Auth(String)
Authentication errors
Unauthorized access
NotFound(String)
Resource not found
Implementations§
Source§impl Error
impl Error
Sourcepub fn scanner<S: Into<String>, M: Into<String>>(scanner: S, message: M) -> Self
pub fn scanner<S: Into<String>, M: Into<String>>(scanner: S, message: M) -> Self
Create a scanner error with context
Sourcepub fn scanner_with_source<S: Into<String>, M: Into<String>>(
scanner: S,
message: M,
source: Box<dyn Error + Send + Sync>,
) -> Self
pub fn scanner_with_source<S: Into<String>, M: Into<String>>( scanner: S, message: M, source: Box<dyn Error + Send + Sync>, ) -> Self
Create a scanner error with source
Sourcepub fn invalid_input<S: Into<String>>(message: S) -> Self
pub fn invalid_input<S: Into<String>>(message: S) -> Self
Create an invalid input error
Sourcepub fn resource_exhausted<S: Into<String>>(resource: S) -> Self
pub fn resource_exhausted<S: Into<String>>(resource: S) -> Self
Create a resource exhausted error
Create an unauthorized error
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if error is retryable
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more