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>(code: ErrorCode, class: ErrorClass, message: S) -> Error
pub fn new<S>(code: ErrorCode, class: ErrorClass, message: S) -> Error
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: i32) -> Option<Error>
pub fn last_error(code: i32) -> Option<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.
Historically this function returned Some
or None
based on the return
value of git_error_last
but nowadays it always returns Some
so it’s
safe to unwrap the return value. This API will change in the next major
version.
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.
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<Error> for CheckoutError
impl From<Error> for CheckoutError
Source§fn from(source: Error) -> CheckoutError
fn from(source: Error) -> CheckoutError
Source§impl From<Error> for FetchError
impl From<Error> for FetchError
Source§fn from(source: Error) -> FetchError
fn from(source: Error) -> FetchError
Source§impl From<Error> for ListRefsError
impl From<Error> for ListRefsError
Source§fn from(source: Error) -> ListRefsError
fn from(source: Error) -> ListRefsError
Source§impl From<Error> for NamespacesError
impl From<Error> for NamespacesError
Source§fn from(source: Error) -> NamespacesError
fn from(source: Error) -> NamespacesError
Source§impl From<Error> for ObjectsError
impl From<Error> for ObjectsError
Source§fn from(source: Error) -> ObjectsError
fn from(source: Error) -> ObjectsError
Source§impl From<Error> for QuorumError
impl From<Error> for QuorumError
Source§fn from(source: Error) -> QuorumError
fn from(source: Error) -> QuorumError
Source§impl From<Error> for RemoteError
impl From<Error> for RemoteError
Source§fn from(source: Error) -> RemoteError
fn from(source: Error) -> RemoteError
Source§impl From<Error> for RepositoryError
impl From<Error> for RepositoryError
Source§fn from(source: Error) -> RepositoryError
fn from(source: Error) -> RepositoryError
Source§impl From<Error> for TypesError
impl From<Error> for TypesError
Source§fn from(source: Error) -> TypesError
fn from(source: Error) -> TypesError
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