errors

package
v1.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package errors provides user-friendly error handling for GitScrum CLI

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotAuthenticated = &CLIError{
		Message:    "You're not logged in yet",
		Suggestion: "Run 'gitscrum auth login' to get started",
		Code:       "AUTH_REQUIRED",
	}

	ErrNoWorkspace = &CLIError{
		Message:    "No workspace configured",
		Suggestion: "Run 'gitscrum config set workspace <slug>' to set a default workspace",
		Code:       "NO_WORKSPACE",
	}

	ErrNoProject = &CLIError{
		Message:    "No project specified",
		Suggestion: "Use --project flag or run 'gitscrum config set project <slug>'",
		Code:       "NO_PROJECT",
	}

	ErrNotInGitRepo = &CLIError{
		Message:    "Not in a git repository",
		Suggestion: "Navigate to a git repository or use explicit flags",
		Code:       "NOT_GIT_REPO",
	}

	ErrNoTaskCode = &CLIError{
		Message:    "Could not detect task code from branch",
		Suggestion: "Specify the task code explicitly, e.g. 'gitscrum tasks view a1b2c3d4'",
		Code:       "NO_TASK_CODE",
	}
)

Common error types

Functions

func FormatError

func FormatError(err error) string

FormatError returns a formatted error string for printing

Types

type CLIError

type CLIError struct {
	Message    string
	Suggestion string
	Code       string
	Cause      error
}

CLIError represents a user-friendly CLI error

func HandleAPIError

func HandleAPIError(resp *http.Response, body string) *CLIError

HandleAPIError converts HTTP errors to friendly messages

func New

func New(message string) *CLIError

New creates a new CLIError

func NewWithSuggestion

func NewWithSuggestion(message, suggestion string) *CLIError

NewWithSuggestion creates a new CLIError with suggestion

func Wrap

func Wrap(err error, message string) *CLIError

Wrap creates a CLIError from a generic error

func WrapWithSuggestion

func WrapWithSuggestion(err error, message, suggestion string) *CLIError

WrapWithSuggestion creates a CLIError with a suggestion

func (*CLIError) Error

func (e *CLIError) Error() string

func (*CLIError) Print

func (e *CLIError) Print()

Print displays the error in a user-friendly format

func (*CLIError) Unwrap

func (e *CLIError) Unwrap() error

func (*CLIError) WithCause

func (e *CLIError) WithCause(err error) *CLIError

WithCause adds the underlying error

Jump to

Keyboard shortcuts

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