pub enum MemScopeError {
Memory {
operation: MemoryOperation,
message: Arc<str>,
context: Option<Arc<str>>,
error_kind: ErrorKind,
error_context: ErrorContext,
},
Analysis {
analyzer: Arc<str>,
message: Arc<str>,
recoverable: bool,
error_kind: ErrorKind,
error_context: ErrorContext,
},
Export {
format: Arc<str>,
message: Arc<str>,
partial_success: bool,
error_kind: ErrorKind,
error_context: ErrorContext,
},
Configuration {
component: Arc<str>,
message: Arc<str>,
error_kind: ErrorKind,
error_context: ErrorContext,
},
System {
error_type: SystemErrorType,
message: Arc<str>,
source_message: Option<Arc<str>>,
error_kind: ErrorKind,
error_context: ErrorContext,
},
Internal {
message: Arc<str>,
location: Option<Arc<str>>,
error_kind: ErrorKind,
error_context: ErrorContext,
},
}Expand description
Unified error type for the entire memscope-rs system
This replaces the complex TrackingError with a simpler, more efficient design while maintaining all existing error information and backward compatibility.
Variants§
Memory
Memory tracking operations (allocation, deallocation, association)
Analysis
Analysis operations (fragmentation, lifecycle, etc.)
Fields
error_context: ErrorContextExport
Export operations (JSON, binary, HTML, etc.)
Fields
error_context: ErrorContextConfiguration
Configuration and initialization errors
System
System-level errors (IO, threading, etc.)
Internal
Internal errors that should not normally occur
Implementations§
Source§impl MemScopeError
impl MemScopeError
Sourcepub fn error(module: &str, method: &str, message: impl Into<Arc<str>>) -> Self
pub fn error(module: &str, method: &str, message: impl Into<Arc<str>>) -> Self
Unified error creation - external modules only need to provide:
- module: which module the error occurred in (e.g., “variable_registry”)
- method: which method/function (e.g., “register_variable”)
- message: what went wrong
Internal classification by module:
- MemoryError: tracker, allocator, variable_registry, memory_tracker, capture
- ExportError: export, render_engine, snapshot
- AnalysisError: ffi_function_resolver, call_stack_normalizer, analysis, lifecycle, rule_engine, pattern_matcher, detector, unsafe_ffi_tracker
- ConfigurationError: config, initialization
- IoError: system errors (io, threading, locking, network, filesystem)
- InternalError: fallback for unknown modules
Sourcepub fn new(kind: ErrorKind, message: impl Into<Arc<str>>) -> Self
pub fn new(kind: ErrorKind, message: impl Into<Arc<str>>) -> Self
Create a new error with the specified kind and message
Sourcepub fn with_context(
kind: ErrorKind,
_severity: ErrorSeverity,
message: impl Into<Arc<str>>,
context: impl Into<Arc<str>>,
) -> Self
pub fn with_context( kind: ErrorKind, _severity: ErrorSeverity, message: impl Into<Arc<str>>, context: impl Into<Arc<str>>, ) -> Self
Create a new error with the specified kind, severity, and context
Sourcepub fn memory(operation: MemoryOperation, message: impl Into<Arc<str>>) -> Self
pub fn memory(operation: MemoryOperation, message: impl Into<Arc<str>>) -> Self
Create a memory operation error
Sourcepub fn memory_with_context(
operation: MemoryOperation,
message: impl Into<Arc<str>>,
context: impl Into<Arc<str>>,
) -> Self
pub fn memory_with_context( operation: MemoryOperation, message: impl Into<Arc<str>>, context: impl Into<Arc<str>>, ) -> Self
Create a memory operation error with context
Sourcepub fn analysis(
analyzer: impl Into<Arc<str>>,
message: impl Into<Arc<str>>,
) -> Self
pub fn analysis( analyzer: impl Into<Arc<str>>, message: impl Into<Arc<str>>, ) -> Self
Create an analysis error
Sourcepub fn analysis_fatal(
analyzer: impl Into<Arc<str>>,
message: impl Into<Arc<str>>,
) -> Self
pub fn analysis_fatal( analyzer: impl Into<Arc<str>>, message: impl Into<Arc<str>>, ) -> Self
Create a non-recoverable analysis error
Sourcepub fn export(format: impl Into<Arc<str>>, message: impl Into<Arc<str>>) -> Self
pub fn export(format: impl Into<Arc<str>>, message: impl Into<Arc<str>>) -> Self
Create an export error
Sourcepub fn export_partial(
format: impl Into<Arc<str>>,
message: impl Into<Arc<str>>,
) -> Self
pub fn export_partial( format: impl Into<Arc<str>>, message: impl Into<Arc<str>>, ) -> Self
Create an export error with partial success
Sourcepub fn export_with_source(
format: impl Into<Arc<str>>,
message: impl Into<Arc<str>>,
source: impl AsRef<str>,
) -> Self
pub fn export_with_source( format: impl Into<Arc<str>>, message: impl Into<Arc<str>>, source: impl AsRef<str>, ) -> Self
Create an export error with source information
Sourcepub fn config(
component: impl Into<Arc<str>>,
message: impl Into<Arc<str>>,
) -> Self
pub fn config( component: impl Into<Arc<str>>, message: impl Into<Arc<str>>, ) -> Self
Create a configuration error
Sourcepub fn system(error_type: SystemErrorType, message: impl Into<Arc<str>>) -> Self
pub fn system(error_type: SystemErrorType, message: impl Into<Arc<str>>) -> Self
Create a system error
Sourcepub fn system_with_source(
error_type: SystemErrorType,
message: impl Into<Arc<str>>,
source: impl Error,
) -> Self
pub fn system_with_source( error_type: SystemErrorType, message: impl Into<Arc<str>>, source: impl Error, ) -> Self
Create a system error with source
Sourcepub fn internal_at(
message: impl Into<Arc<str>>,
location: impl Into<Arc<str>>,
) -> Self
pub fn internal_at( message: impl Into<Arc<str>>, location: impl Into<Arc<str>>, ) -> Self
Create an internal error with location
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Check if this error is recoverable
Sourcepub fn severity(&self) -> ErrorSeverity
pub fn severity(&self) -> ErrorSeverity
Get error severity level
Sourcepub fn user_message(&self) -> &str
pub fn user_message(&self) -> &str
Get a user-friendly error message
Sourcepub fn context(&self) -> &ErrorContext
pub fn context(&self) -> &ErrorContext
Get error context information
Sourcepub fn description(&self) -> String
pub fn description(&self) -> String
Get a detailed error description
Trait Implementations§
Source§impl Clone for MemScopeError
impl Clone for MemScopeError
Source§fn clone(&self) -> MemScopeError
fn clone(&self) -> MemScopeError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MemScopeError
impl Debug for MemScopeError
Source§impl Display for MemScopeError
impl Display for MemScopeError
Source§impl Error for MemScopeError
impl Error for MemScopeError
1.30.0 · 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
use the Display impl or to_string()
Source§impl From<Error> for MemScopeError
impl From<Error> for MemScopeError
Source§impl From<Error> for MemScopeError
impl From<Error> for MemScopeError
Source§impl From<ExportError> for MemScopeError
impl From<ExportError> for MemScopeError
Source§fn from(err: ExportError) -> Self
fn from(err: ExportError) -> Self
Auto Trait Implementations§
impl Freeze for MemScopeError
impl RefUnwindSafe for MemScopeError
impl Send for MemScopeError
impl Sync for MemScopeError
impl Unpin for MemScopeError
impl UnsafeUnpin for MemScopeError
impl UnwindSafe for MemScopeError
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