pub enum Error {
Io(Error),
Json(Error),
Config {
key: String,
message: String,
context: Option<Box<ErrorContext>>,
},
Parse {
file: PathBuf,
message: String,
line: Option<usize>,
context: Option<Box<ErrorContext>>,
},
Network {
message: String,
context: Option<Box<ErrorContext>>,
},
Database {
message: String,
context: Option<Box<ErrorContext>>,
},
ResourceExhausted {
resource: String,
message: String,
context: Option<Box<ErrorContext>>,
},
Timeout {
operation: String,
timeout: Duration,
context: Option<Box<ErrorContext>>,
},
Cancelled {
operation: String,
context: Option<Box<ErrorContext>>,
},
Permission {
resource: String,
message: String,
context: Option<Box<ErrorContext>>,
},
Validation {
field: String,
message: String,
context: Option<Box<ErrorContext>>,
},
Generic {
message: String,
severity: ErrorSeverity,
recovery_strategy: RecoveryStrategy,
context: Option<Box<ErrorContext>>,
},
}
Expand description
The main error type for the codeprism library
Variants§
Io(Error)
Input/output related errors
Json(Error)
JSON serialization/deserialization errors
Config
Configuration related errors
Fields
context: Option<Box<ErrorContext>>
Error context for correlation and debugging
Parse
Parsing related errors
Fields
context: Option<Box<ErrorContext>>
Error context for correlation and debugging
Network
Network related errors
Fields
context: Option<Box<ErrorContext>>
Error context for correlation and debugging
Database
Database related errors
Fields
context: Option<Box<ErrorContext>>
Error context for correlation and debugging
ResourceExhausted
Resource exhaustion errors
Fields
context: Option<Box<ErrorContext>>
Error context for correlation and debugging
Timeout
Timeout errors
Fields
context: Option<Box<ErrorContext>>
Error context for correlation and debugging
Cancelled
Operation was cancelled
Fields
context: Option<Box<ErrorContext>>
Error context for correlation and debugging
Permission
Permission/authorization errors
Fields
context: Option<Box<ErrorContext>>
Error context for correlation and debugging
Validation
Input validation errors
Fields
context: Option<Box<ErrorContext>>
Error context for correlation and debugging
Generic
Generic errors for cases not covered by specific types
Fields
severity: ErrorSeverity
Error severity
recovery_strategy: RecoveryStrategy
Recovery strategy suggestion
context: Option<Box<ErrorContext>>
Error context for correlation and debugging
Implementations§
Source§impl Error
impl Error
Sourcepub fn get_error_code(&self) -> &'static str
pub fn get_error_code(&self) -> &'static str
Get error code for logging and monitoring
Sourcepub fn get_severity(&self) -> ErrorSeverity
pub fn get_severity(&self) -> ErrorSeverity
Get error severity
Sourcepub fn get_recovery_strategy(&self) -> RecoveryStrategy
pub fn get_recovery_strategy(&self) -> RecoveryStrategy
Get recovery strategy
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Check if error is recoverable
Sourcepub fn get_context(&self) -> Option<&ErrorContext>
pub fn get_context(&self) -> Option<&ErrorContext>
Get error context if available
Sourcepub fn parse_with_context(
file: impl Into<PathBuf>,
message: impl Into<String>,
context: ErrorContext,
) -> Self
pub fn parse_with_context( file: impl Into<PathBuf>, message: impl Into<String>, context: ErrorContext, ) -> Self
Create a parse error with context
Sourcepub fn parse(file: impl Into<PathBuf>, message: impl Into<String>) -> Self
pub fn parse(file: impl Into<PathBuf>, message: impl Into<String>) -> Self
Create a simple parse error
Sourcepub fn config(key: impl Into<String>, message: impl Into<String>) -> Self
pub fn config(key: impl Into<String>, message: impl Into<String>) -> Self
Create a configuration error
Sourcepub fn permission(
resource: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn permission( resource: impl Into<String>, message: impl Into<String>, ) -> Self
Create a permission error
Sourcepub fn validation(field: impl Into<String>, message: impl Into<String>) -> Self
pub fn validation(field: impl Into<String>, message: impl Into<String>) -> Self
Create a validation error
Sourcepub fn generic(
message: impl Into<String>,
severity: ErrorSeverity,
recovery_strategy: RecoveryStrategy,
) -> Self
pub fn generic( message: impl Into<String>, severity: ErrorSeverity, recovery_strategy: RecoveryStrategy, ) -> Self
Create a generic error
Sourcepub fn resource_exhausted(
resource: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn resource_exhausted( resource: impl Into<String>, message: impl Into<String>, ) -> Self
Create a resource exhausted error
Sourcepub fn storage(message: impl Into<String>) -> Self
pub fn storage(message: impl Into<String>) -> Self
Create a storage error (mapped to database error)
Sourcepub fn watcher(message: impl Into<String>) -> Self
pub fn watcher(message: impl Into<String>) -> Self
Create a watcher error (mapped to generic error)
Sourcepub fn indexing(message: impl Into<String>) -> Self
pub fn indexing(message: impl Into<String>) -> Self
Create an indexing error (mapped to generic error)
Sourcepub fn unsupported_language(language: impl Into<String>) -> Self
pub fn unsupported_language(language: impl Into<String>) -> Self
Create an unsupported language error (mapped to validation error)
Sourcepub fn node_not_found(node_id: impl Into<String>) -> Self
pub fn node_not_found(node_id: impl Into<String>) -> Self
Create a node not found error (mapped to validation error)
Sourcepub fn should_retry(&self) -> bool
pub fn should_retry(&self) -> bool
Check if this error should trigger a retry
Sourcepub fn severity(&self) -> ErrorSeverity
pub fn severity(&self) -> ErrorSeverity
Get the severity level of this error (for backward compatibility)
Sourcepub fn recovery_strategy(&self) -> RecoveryStrategy
pub fn recovery_strategy(&self) -> RecoveryStrategy
Get the recovery strategy for this error (for backward compatibility)
Sourcepub fn error_code(&self) -> i32
pub fn error_code(&self) -> i32
Get error code for JSON-RPC responses (for backward compatibility)
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)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more