Documentation
¶
Index ¶
- func As(err error, target interface{}) bool
- func IsAPIError(err error) bool
- func IsAuthError(err error) bool
- func IsNetworkError(err error) bool
- func IsVerboseMode() bool
- func IsVersionError(err error) bool
- func NewLoggingHTTPClient() *http.Client
- func SetVerboseMode(enabled bool)
- func SuggestForAuth(statusCode int, host string) string
- func SuggestForNetwork(host string) string
- func SuggestForStatusCode(statusCode int) string
- func WrapAPIError(err error, method, url string, statusCode int) error
- type APIError
- type AuthError
- type NetworkError
- type VersionError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func As ¶
As is a convenience wrapper around errors.As from the standard library. It finds the first error in err's chain that matches target's type.
func IsAPIError ¶
IsAPIError checks if an error is or wraps an APIError.
func IsAuthError ¶
IsAuthError checks if an error is or wraps an AuthError.
func IsNetworkError ¶
IsNetworkError checks if an error is or wraps a NetworkError.
func IsVerboseMode ¶
func IsVerboseMode() bool
IsVerboseMode returns whether verbose mode is enabled.
func IsVersionError ¶
IsVersionError checks if an error is or wraps a VersionError.
func NewLoggingHTTPClient ¶
NewLoggingHTTPClient creates an HTTP client that logs requests/responses in verbose mode.
func SetVerboseMode ¶
func SetVerboseMode(enabled bool)
SetVerboseMode enables or disables verbose error output.
func SuggestForAuth ¶
SuggestForAuth returns an actionable suggestion for authentication errors.
func SuggestForNetwork ¶
SuggestForNetwork returns an actionable suggestion for network errors.
func SuggestForStatusCode ¶
SuggestForStatusCode returns an actionable suggestion based on HTTP status code.
Types ¶
type APIError ¶
type APIError struct {
// Method is the HTTP method (GET, POST, PUT, DELETE, etc.)
Method string
// URL is the full request URL that failed
URL string
// StatusCode is the HTTP status code from the response
StatusCode int
// Message is the error message from the API or a descriptive error
Message string
// Suggestion provides actionable guidance to resolve the error
Suggestion string
// Err is the underlying error that caused this API error
Err error
}
APIError represents an error from a GitLab API request with detailed context.
func NewAPIError ¶
NewAPIError creates a new APIError with the given details. The suggestion is automatically generated from the status code if not provided.
func (*APIError) ErrorDetails ¶
ErrorDetails returns structured details for JSON error formatting.
type AuthError ¶
type AuthError struct {
// Host is the GitLab host where authentication failed
Host string
// Method is the HTTP method (GET, POST, PUT, DELETE, etc.)
Method string
// URL is the full request URL that failed
URL string
// StatusCode is the HTTP status code (typically 401 or 403)
StatusCode int
// Message is a descriptive error message
Message string
// Suggestion provides actionable guidance to resolve the auth issue
Suggestion string
// Err is the underlying error
Err error
}
AuthError represents an authentication or authorization error.
func NewAuthError ¶
NewAuthError creates a new AuthError with the given details. The suggestion is automatically generated from the status code and host if not provided.
func (*AuthError) ErrorDetails ¶
ErrorDetails returns structured details for JSON error formatting.
type NetworkError ¶
type NetworkError struct {
// Host is the remote host that could not be reached
Host string
// URL is the full request URL that failed
URL string
// Message is a descriptive error message
Message string
// Suggestion provides actionable guidance to resolve the network issue
Suggestion string
// Err is the underlying error
Err error
}
NetworkError represents a network connectivity error.
func NewNetworkError ¶
func NewNetworkError(host, url, message string, err error) *NetworkError
NewNetworkError creates a new NetworkError with the given details. The suggestion is automatically generated from the host if not provided.
func (*NetworkError) Error ¶
func (e *NetworkError) Error() string
Error implements the error interface.
func (*NetworkError) ErrorCode ¶
func (e *NetworkError) ErrorCode() string
ErrorCode returns the error code for this NetworkError.
func (*NetworkError) ErrorDetails ¶
func (e *NetworkError) ErrorDetails() map[string]interface{}
ErrorDetails returns structured details for JSON error formatting.
func (*NetworkError) Unwrap ¶
func (e *NetworkError) Unwrap() error
Unwrap returns the underlying error.
type VersionError ¶
type VersionError struct {
// RequiredVersion is the minimum GitLab version required
RequiredVersion string
// ActualVersion is the detected GitLab version
ActualVersion string
// Feature is the feature or operation that requires the minimum version
Feature string
// Message is a descriptive error message
Message string
// Suggestion provides actionable guidance to resolve the version issue
Suggestion string
// Err is the underlying error
Err error
}
VersionError represents a GitLab API version mismatch error.
func NewVersionError ¶
func NewVersionError(requiredVersion, actualVersion, feature, message string, err error) *VersionError
NewVersionError creates a new VersionError with the given details.
func (*VersionError) Error ¶
func (e *VersionError) Error() string
Error implements the error interface.
func (*VersionError) Unwrap ¶
func (e *VersionError) Unwrap() error
Unwrap returns the underlying error.