GitLabError

Enum GitLabError 

Source
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

§resource: String

The type of resource (e.g., “pipeline”, “job”, “project”)

§id: String

The identifier for the resource

§

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.

Fields

§retry_after: Option<u64>

Number of seconds to wait before retrying (if provided by GitLab)

§

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

§field: String

The field name that has invalid input

§message: String

Description of why the input is invalid

§

Timeout

Operation timed out.

This can occur when waiting for a pipeline to complete, polling for status, etc.

Fields

§seconds: u64

Number of seconds elapsed before timeout

§

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

Source

pub fn authentication<S: Into<String>>(msg: S) -> Self

Creates an authentication error.

§Examples
let error = GitLabError::authentication("Token expired");
Source

pub fn api<S: Into<String>>(msg: S) -> Self

Creates an API error.

§Examples
let error = GitLabError::api("Invalid project path");
Source

pub fn not_found<S: Into<String>, I: Display>(resource: S, id: I) -> Self

Creates a not found error.

§Examples
let error = GitLabError::not_found("pipeline", 12345);
Source

pub fn config<S: Into<String>>(msg: S) -> Self

Creates a configuration error.

§Examples
let error = GitLabError::config("Missing API token");
Source

pub fn rate_limit(retry_after: Option<u64>) -> Self

Creates a rate limit error.

§Examples
let error = GitLabError::rate_limit(Some(60));
Source

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");
Source

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");
Source

pub fn timeout(seconds: u64) -> Self

Creates a timeout error.

§Examples
let error = GitLabError::timeout(300);
Source

pub fn conflict<S: Into<String>>(msg: S) -> Self

Creates a conflict error.

§Examples
let error = GitLabError::conflict("Pipeline already exists");
Source

pub fn server_error<S: Into<String>>(msg: S) -> Self

Creates a server error.

§Examples
let error = GitLabError::server_error("Internal server error");
Source

pub fn unexpected<S: Into<String>>(msg: S) -> Self

Creates an unexpected error.

§Examples
let error = GitLabError::unexpected("Unknown error occurred");
Source

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());
Source

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.

Source

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

Source§

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

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

impl Display for GitLabError

Source§

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

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

impl Error for GitLabError

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 GitLabError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for GitLabError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more