Skip to main content

Error

Struct Error 

Source
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 drop
  • Error<'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>

Source

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.

Source

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.

Source

pub fn from_message(msg: &str) -> Error<'static>

Creates a new error from a string message.

Source

pub fn from_raw(err: *mut svn_error_t) -> Result<(), Error<'static>>

Creates an error from a raw SVN error pointer, or Ok if null.

Source§

impl<'a> Error<'a>

Source

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.

Source

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).

Source

pub fn as_mut_ptr(&mut self) -> *mut svn_error_t

Gets the mutable raw pointer to the error.

Source

pub fn as_ptr(&self) -> *const svn_error_t

Gets the raw pointer to the error.

Source

pub fn line(&self) -> i64

Gets the line number where the error occurred.

Source

pub fn file(&self) -> Option<&str>

Gets the file name where the error occurred.

Source

pub fn location(&self) -> Option<(&str, i64)>

Gets the file and line location where the error occurred.

Source

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.

Source

pub fn message(&self) -> Option<&str>

Gets the error message.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn best_message(&self) -> String

Gets the best available error message from the error chain.

Source

pub fn full_message(&self) -> String

Collect all messages from the error chain

Source

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 Clone for Error<'static>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Error<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Error<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Error for Error<'_>

1.30.0 · Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error<'_>> for Error

Source§

fn from(err: Error<'_>) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error<'static>

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<NulError> for Error<'static>

Source§

fn from(err: NulError) -> Self

Converts to this type from the input type.
Source§

impl From<Utf8Error> for Error<'static>

Source§

fn from(err: Utf8Error) -> Self

Converts to this type from the input type.
Source§

impl Send for Error<'_>

Auto Trait Implementations§

§

impl<'a> Freeze for Error<'a>

§

impl<'a> RefUnwindSafe for Error<'a>

§

impl<'a> !Sync for Error<'a>

§

impl<'a> Unpin for Error<'a>

§

impl<'a> UnsafeUnpin for Error<'a>

§

impl<'a> UnwindSafe for Error<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.