pub enum GitLabError {
Show 13 variants
Authentication(String),
Api(String),
Http(Error),
NotFound {
resource: String,
id: String,
},
Config(String),
Serialization(Error),
RateLimit {
retry_after: Option<u64>,
},
PermissionDenied(String),
InvalidInput {
field: String,
message: String,
},
Timeout {
seconds: u64,
},
Conflict(String),
ServerError(String),
Unexpected(String),
}Expand description
The main error type for all GitLab client operations.
This enum covers all possible error scenarios including authentication, API errors, network issues, and data validation problems.
Variants§
Authentication(String)
Authentication failed due to invalid or missing credentials.
§Examples
let error = GitLabError::Authentication("Invalid token".to_string());
assert_eq!(error.to_string(), "Authentication failed: Invalid token");Api(String)
GitLab API returned an error response.
This includes HTTP error codes, API-specific errors, and malformed responses.
Http(Error)
HTTP request failed due to network or connection issues.
NotFound
Requested resource was not found (HTTP 404).
§Examples
let error = GitLabError::NotFound {
resource: "pipeline".to_string(),
id: "12345".to_string(),
};Fields
Config(String)
Invalid configuration provided to the client.
This includes invalid URLs, missing required fields, or incompatible settings.
Serialization(Error)
Failed to serialize or deserialize data.
RateLimit
Rate limit exceeded for API requests.
GitLab enforces rate limits on API calls. When exceeded, this error is returned.
PermissionDenied(String)
Operation is not permitted due to insufficient permissions.
InvalidInput
Invalid input or parameters provided.
§Examples
let error = GitLabError::InvalidInput {
field: "status".to_string(),
message: "Must be one of: success, failed, running".to_string(),
};Fields
Timeout
Operation timed out.
This can occur when waiting for a pipeline to complete, polling for status, etc.
Conflict(String)
The underlying GitLab API returned a status that indicates a conflict (HTTP 409).
Common scenarios include attempting to create a resource that already exists.
ServerError(String)
The GitLab server is unavailable or returned an error (HTTP 5xx).
Unexpected(String)
An unexpected or unknown error occurred.
This is used as a catch-all for errors that don’t fit other categories.
Implementations§
Source§impl GitLabError
impl GitLabError
Sourcepub fn authentication<S: Into<String>>(msg: S) -> Self
pub fn authentication<S: Into<String>>(msg: S) -> Self
Creates an authentication error.
§Examples
let error = GitLabError::authentication("Token expired");Sourcepub fn rate_limit(retry_after: Option<u64>) -> Self
pub fn rate_limit(retry_after: Option<u64>) -> Self
Sourcepub fn permission_denied<S: Into<String>>(msg: S) -> Self
pub fn permission_denied<S: Into<String>>(msg: S) -> Self
Creates a permission denied error.
§Examples
let error = GitLabError::permission_denied("Cannot delete protected branch");Sourcepub fn invalid_input<S: Into<String>, M: Into<String>>(
field: S,
message: M,
) -> Self
pub fn invalid_input<S: Into<String>, M: Into<String>>( field: S, message: M, ) -> Self
Creates an invalid input error.
§Examples
let error = GitLabError::invalid_input("ref", "Branch name cannot be empty");Sourcepub fn server_error<S: Into<String>>(msg: S) -> Self
pub fn server_error<S: Into<String>>(msg: S) -> Self
Sourcepub fn unexpected<S: Into<String>>(msg: S) -> Self
pub fn unexpected<S: Into<String>>(msg: S) -> Self
Creates an unexpected error.
§Examples
let error = GitLabError::unexpected("Unknown error occurred");Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if this error is retryable.
Retryable errors include network issues, rate limits, and server errors.
§Examples
let error = GitLabError::rate_limit(Some(60));
assert!(error.is_retryable());
let error = GitLabError::not_found("pipeline", 123);
assert!(!error.is_retryable());Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Returns true if this is a client error (4xx status codes).
Client errors indicate problems with the request that cannot be resolved by retrying.
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Returns true if this is a server error (5xx status codes).
Trait Implementations§
Source§impl Debug for GitLabError
impl Debug for GitLabError
Source§impl Display for GitLabError
impl Display for GitLabError
Source§impl Error for GitLabError
impl Error for GitLabError
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 GitLabError
impl From<Error> for GitLabError
Auto Trait Implementations§
impl Freeze for GitLabError
impl !RefUnwindSafe for GitLabError
impl Send for GitLabError
impl Sync for GitLabError
impl Unpin for GitLabError
impl !UnwindSafe for GitLabError
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> 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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.