errors

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package errors provides error types and translation utilities for GitHub API errors.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound indicates that the requested resource was not found.
	ErrNotFound = errors.New("not found")

	// ErrPermissionDenied indicates insufficient permissions for the operation.
	ErrPermissionDenied = errors.New("permission denied")

	// ErrRateLimited indicates the API rate limit has been exceeded.
	ErrRateLimited = errors.New("rate limit exceeded")

	// ErrConflict indicates a conflict (e.g., resource already exists).
	ErrConflict = errors.New("conflict")

	// ErrValidation indicates a validation error in the request.
	ErrValidation = errors.New("validation failed")

	// ErrServerError indicates a GitHub server error.
	ErrServerError = errors.New("server error")
)

Standard errors for GitHub operations.

Functions

func IsConflict

func IsConflict(err error) bool

IsConflict returns true if the error indicates a conflict.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the error indicates a not found condition.

func IsPermissionDenied

func IsPermissionDenied(err error) bool

IsPermissionDenied returns true if the error indicates a permission issue.

func IsRateLimited

func IsRateLimited(err error) bool

IsRateLimited returns true if the error indicates rate limiting.

func IsServerError

func IsServerError(err error) bool

IsServerError returns true if the error indicates a server error.

func IsValidation

func IsValidation(err error) bool

IsValidation returns true if the error indicates a validation failure.

func StatusCode

func StatusCode(err error) int

StatusCode extracts the HTTP status code from an error, if available. Returns 0 if the status code cannot be determined.

func Translate

func Translate(err error, resp *github.Response) error

Translate converts a GitHub API error to a standard error. It examines both the response status code and the error type to return an appropriate standard error.

The returned error wraps the original error, so the caller can use errors.Unwrap or errors.Is/As to access the original.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
	Err        error
}

APIError wraps a GitHub API error with additional context.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Is

func (e *APIError) Is(target error) bool

Is implements error matching for APIError.

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

Jump to

Keyboard shortcuts

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