errors

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package errors provides custom error types for GitHubby

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingToken      = errors.New("missing required argument 'token'")
	ErrMissingRepository = errors.New("missing required argument 'repository'")
	ErrMissingFilter     = errors.New("missing at least one filter flag (run with --help for more information)")
	ErrInvalidRepository = errors.New("invalid repository format (expected owner/repo)")
	ErrRateLimited       = errors.New("GitHub API rate limit exceeded")
	ErrNotFound          = errors.New("resource not found")
	ErrUnauthorized      = errors.New("unauthorized: invalid or expired token")
	ErrForbidden         = errors.New("forbidden: insufficient permissions")
)

Common errors

Functions

func IsForbidden added in v1.0.12

func IsForbidden(err error) bool

IsForbidden checks if the error is a forbidden (403 permission-denied) error

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if the error is a not found error

func IsRateLimited

func IsRateLimited(err error) bool

IsRateLimited checks if the error is a rate limit error. Only matches ErrRateLimited sentinel and 429 APIError status codes. Permission-denied 403s use ErrForbidden instead and are NOT retried.

func IsUnauthorized added in v1.0.12

func IsUnauthorized(err error) bool

IsUnauthorized checks if the error is an unauthorized (401) error

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
	Err        error
}

APIError represents a GitHub API error

func NewAPIError

func NewAPIError(statusCode int, message string, err error) *APIError

NewAPIError creates a new API error

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

type AuthError

type AuthError struct {
	Message string
}

AuthError represents an authentication error with helpful guidance

func NewAuthError

func NewAuthError() *AuthError

NewAuthError creates a user-friendly authentication error

func NewAuthErrorWithReason added in v1.0.12

func NewAuthErrorWithReason(reason string) *AuthError

NewAuthErrorWithReason creates a user-friendly authentication error that includes a specific reason

func NewExpiredTokenError added in v1.0.12

func NewExpiredTokenError(source string) *AuthError

NewExpiredTokenError creates an auth error that identifies which token source failed

func (*AuthError) Error

func (e *AuthError) Error() string

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents an input validation error

func NewValidationError

func NewValidationError(field, message string) *ValidationError

NewValidationError creates a new validation error

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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