pub struct Error<'a> { /* private fields */ }Expand description
Represents a Subversion error.
SVN errors can form chains where each error points to a child error that provides more context. The lifetime parameter tracks ownership of the error chain:
Error<'static>owns its error pointer and will free the entire chain on dropError<'a>borrows from another error’s chain and shares the pointer without owning it
§Examples
Creating a simple error:
use subversion::Error;
let err = Error::from_message("Something went wrong");Checking error details:
println!("Error code: {}", err.code());
println!("Error message: {}", err.message());
println!("Error category: {:?}", err.category());Traversing an error chain:
let mut current = Some(&err);
while let Some(e) = current {
println!("Error: {}", e.message());
current = e.child().as_ref();
}Implementations§
Source§impl Error<'static>
impl Error<'static>
Sourcepub fn new(status: Status, child: Option<Error<'static>>, msg: &str) -> Self
pub fn new(status: Status, child: Option<Error<'static>>, msg: &str) -> Self
Creates a new error with the given status, optional child error, and message.
Sourcepub fn with_raw_status(
status: i32,
child: Option<Error<'static>>,
msg: &str,
) -> Self
pub fn with_raw_status( status: i32, child: Option<Error<'static>>, msg: &str, ) -> Self
Creates a new error with a raw APR/SVN status code.
Use this when you need SVN-specific error codes (like SVN_ERR_CANCELLED)
that cannot be represented by apr::Status.
Sourcepub fn from_message(msg: &str) -> Error<'static>
pub fn from_message(msg: &str) -> Error<'static>
Creates a new error from a string message.
Source§impl<'a> Error<'a>
impl<'a> Error<'a>
Sourcepub fn apr_err(&self) -> Status
pub fn apr_err(&self) -> Status
Gets the APR error status code.
Note: SVN-specific error codes (like SVN_ERR_CANCELLED) are mapped to
apr::Status::General because they fall outside the standard APR status range.
Use raw_apr_err() when you need to distinguish SVN error codes.
Sourcepub fn raw_apr_err(&self) -> i32
pub fn raw_apr_err(&self) -> i32
Gets the raw APR/SVN error status code as an integer.
Unlike apr_err(), this preserves the full error code
including SVN-specific codes (e.g. SVN_ERR_CANCELLED = 200015).
Sourcepub fn as_mut_ptr(&mut self) -> *mut svn_error_t
pub fn as_mut_ptr(&mut self) -> *mut svn_error_t
Gets the mutable raw pointer to the error.
Sourcepub fn as_ptr(&self) -> *const svn_error_t
pub fn as_ptr(&self) -> *const svn_error_t
Gets the raw pointer to the error.
Sourcepub fn location(&self) -> Option<(&str, i64)>
pub fn location(&self) -> Option<(&str, i64)>
Gets the file and line location where the error occurred.
Sourcepub fn child(&self) -> Option<Error<'a>>
pub fn child(&self) -> Option<Error<'a>>
Gets the child error, if any.
The returned error has the same lifetime as this error (both are part of the same error chain). The returned error does not own its pointer - the parent error owns the entire chain.
Sourcepub fn find_cause(&self, status: Status) -> Option<Error<'a>>
pub fn find_cause(&self, status: Status) -> Option<Error<'a>>
Finds an error in the chain with the given status code.
The returned error borrows from this error’s chain and does not own its pointer.
Sourcepub fn purge_tracing(&self) -> Error<'_>
pub fn purge_tracing(&self) -> Error<'_>
Removes tracing information from the error.
The returned error borrows from this error’s chain and does not own its pointer.
Sourcepub unsafe fn detach(&mut self) -> *mut svn_error_t
pub unsafe fn detach(&mut self) -> *mut svn_error_t
Detaches the error, returning the raw pointer and preventing cleanup.
§Safety
The caller assumes responsibility for managing the returned pointer’s lifetime and ensuring it is properly freed using Subversion’s error handling functions.
Sourcepub unsafe fn into_raw(self) -> *mut svn_error_t
pub unsafe fn into_raw(self) -> *mut svn_error_t
Converts the error into a raw pointer, consuming self without cleanup.
§Safety
The caller assumes responsibility for managing the returned pointer’s lifetime and ensuring it is properly freed using Subversion’s error handling functions.
Sourcepub fn best_message(&self) -> String
pub fn best_message(&self) -> String
Gets the best available error message from the error chain.
Sourcepub fn full_message(&self) -> String
pub fn full_message(&self) -> String
Collect all messages from the error chain
Sourcepub fn category(&self) -> ErrorCategory
pub fn category(&self) -> ErrorCategory
Returns the error category based on the SVN error code.
This allows programmatic handling of different error types without parsing error messages.
§Example
let mut ctx = subversion::client::Context::new()?;
match ctx.checkout("https://svn.example.com/repo", "/tmp/wc", None, true) {
Ok(_) => println!("Success"),
Err(e) => match e.category() {
ErrorCategory::Authentication => println!("Authentication required"),
ErrorCategory::Authorization => println!("Permission denied"),
ErrorCategory::Io => println!("I/O error occurred"),
_ => println!("Other error: {}", e),
}
}Trait Implementations§
Source§impl Error for Error<'_>
impl Error for Error<'_>
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()