pub struct Error { /* private fields */ }
Expand description
A structure to represent errors coming out of libgit2.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new<S: AsRef<str>>(
code: ErrorCode,
class: ErrorClass,
message: S,
) -> Self
pub fn new<S: AsRef<str>>( code: ErrorCode, class: ErrorClass, message: S, ) -> Self
Creates a new error.
This is mainly intended for implementers of custom transports or
database backends, where it is desirable to propagate an Error
through libgit2
.
Sourcepub fn last_error(code: c_int) -> Error
pub fn last_error(code: c_int) -> Error
Returns the last error that happened with the code specified by code
.
The code
argument typically comes from the return value of a function
call. This code will later be returned from the code
function.
Sourcepub fn from_str(s: &str) -> Error
pub fn from_str(s: &str) -> Error
Creates a new error from the given string as the error.
The error returned will have the code GIT_ERROR
and the class
GIT_ERROR_NONE
.
Sourcepub fn code(&self) -> ErrorCode
pub fn code(&self) -> ErrorCode
Return the error code associated with this error.
An error code is intended to be programmatically actionable most of the
time. For example the code GIT_EAGAIN
indicates that an error could be
fixed by trying again, while the code GIT_ERROR
is more bland and
doesn’t convey anything in particular.
Sourcepub fn set_code(&mut self, code: ErrorCode)
pub fn set_code(&mut self, code: ErrorCode)
Modify the error code associated with this error.
This is mainly intended to be used by implementers of custom transports or database backends, and should be used with care.
Sourcepub fn class(&self) -> ErrorClass
pub fn class(&self) -> ErrorClass
Return the error class associated with this error.
Error classes are in general mostly just informative. For example the class will show up in the error message but otherwise an error class is typically not directly actionable.
Sourcepub fn set_class(&mut self, class: ErrorClass)
pub fn set_class(&mut self, class: ErrorClass)
Modify the error class associated with this error.
This is mainly intended to be used by implementers of custom transports or database backends, and should be used with care.
Sourcepub fn raw_code(&self) -> git_error_code
pub fn raw_code(&self) -> git_error_code
Return the raw error code associated with this error.
Sourcepub fn raw_class(&self) -> git_error_t
pub fn raw_class(&self) -> git_error_t
Return the raw error class associated with this error.
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
Source§impl From<JoinPathsError> for Error
impl From<JoinPathsError> for Error
Source§fn from(e: JoinPathsError) -> Error
fn from(e: JoinPathsError) -> Error
impl StructuralPartialEq for Error
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> 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