errors

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsForbidden

func IsForbidden(err error) bool

IsForbidden checks if an error is a 403 Forbidden error.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if an error is a 404 Not Found error.

func IsRateLimit

func IsRateLimit(err error) bool

IsRateLimit checks if an error is a 429 Rate Limit error.

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized checks if an error is a 401 Unauthorized error.

Types

type BBError

type BBError struct {
	// Message is the human-readable description of what went wrong
	Message string

	// Suggestion provides actionable guidance for resolving the error
	Suggestion string

	// StatusCode is the HTTP status code if this is an API error (0 if not applicable)
	StatusCode int

	// Err is the underlying error that caused this error (can be nil)
	Err error
}

BBError represents a structured error with user-friendly messages and suggestions. It provides context about what went wrong and actionable steps to resolve the issue.

func ConfigError

func ConfigError(message string) *BBError

ConfigError creates an error for configuration-related failures.

func Forbidden

func Forbidden(action string) *BBError

Forbidden creates an error for authorization failures (403).

func GitError

func GitError(operation string, err error) *BBError

GitError creates an error for git-related failures.

func InvalidInput

func InvalidInput(field, reason string) *BBError

InvalidInput creates an error for invalid user input.

func NetworkError

func NetworkError(err error) *BBError

NetworkError creates an error for network-related failures.

func New

func New(message string) *BBError

New creates a new BBError with the given message.

func NotFound

func NotFound(resourceType, identifier string) *BBError

NotFound creates an error for when a resource is not found (404).

func ParseAPIError

func ParseAPIError(resp *http.Response, body []byte) *BBError

ParseAPIError parses an HTTP response and creates an appropriate BBError. It extracts error details from the Bitbucket API JSON response and rate limit headers.

func RateLimit

func RateLimit(resetTime string) *BBError

RateLimit creates an error for rate limiting (429).

func Unauthorized

func Unauthorized(message string) *BBError

Unauthorized creates an error for authentication failures (401).

func WithSuggestion

func WithSuggestion(err error, suggestion string) *BBError

WithSuggestion adds a suggestion to an existing BBError or creates a new one.

func Wrap

func Wrap(err error, message string) *BBError

Wrap wraps an existing error with additional context.

func (*BBError) Error

func (e *BBError) Error() string

Error implements the error interface. It returns a formatted error message that includes the message, suggestion, and underlying error.

func (*BBError) Unwrap

func (e *BBError) Unwrap() error

Unwrap returns the underlying error, allowing errors.Is and errors.As to work correctly.

type BitbucketAPIError

type BitbucketAPIError struct {
	Type    string `json:"type"`
	Error   Error  `json:"error"`
	Message string `json:"message,omitempty"`
}

BitbucketAPIError represents the JSON error response from the Bitbucket API. See: https://developer.atlassian.com/cloud/bitbucket/rest/intro/#error-responses

type Error

type Error struct {
	Message string                 `json:"message"`
	Detail  string                 `json:"detail,omitempty"`
	Data    map[string]interface{} `json:"data,omitempty"`
}

Error is the detailed error object in Bitbucket API responses.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL