errors

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package errors defines the CLIError type used across all jira-cli commands. Every command returns errors (never os.Exit); main.go renders them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLIError

type CLIError struct {
	Code       ErrorCode              `json:"code"`
	Message    string                 `json:"message"`
	Context    map[string]interface{} `json:"context,omitempty"`
	Suggestion string                 `json:"suggestion,omitempty"`
	ExitCode   int                    `json:"-"`
	Err        error                  `json:"-"`
}

CLIError is a structured error carrying machine-readable code, context, and an actionable suggestion for self-correction by humans and agents.

func NewAmbiguousUserError

func NewAmbiguousUserError(message string, matches []map[string]interface{}) *CLIError

NewAmbiguousUserError creates an AMBIGUOUS_USER (exit 3) with match candidates.

func NewAuthError

func NewAuthError(message string) *CLIError

NewAuthError creates an AUTH_ERROR (exit 2).

func NewConflictError

func NewConflictError(message string) *CLIError

NewConflictError creates a CONFLICT_ERROR (exit 8).

func NewGeneralError

func NewGeneralError(message string) *CLIError

NewGeneralError creates a GENERAL_ERROR (exit 1).

func NewMissingFieldError

func NewMissingFieldError(field, issueType string) *CLIError

NewMissingFieldError creates a MISSING_FIELD (exit 3) with field and type context.

func NewNetworkError

func NewNetworkError(message string, instance string) *CLIError

NewNetworkError creates a NETWORK_ERROR (exit 7) with instance context.

func NewNotFoundError

func NewNotFoundError(message string, key string) *CLIError

NewNotFoundError creates a NOT_FOUND (exit 4) with optional key context.

func NewPermissionError

func NewPermissionError(message string) *CLIError

NewPermissionError creates a PERMISSION_DENIED (exit 5).

func NewRateLimitError

func NewRateLimitError(message string) *CLIError

NewRateLimitError creates a RATE_LIMITED (exit 6).

func NewTransitionError

func NewTransitionError(message string, available []map[string]interface{}) *CLIError

NewTransitionError creates an INVALID_TRANSITION (exit 3) with available transitions.

func NewUnknownTypeError

func NewUnknownTypeError(message string) *CLIError

NewUnknownTypeError creates an UNKNOWN_TYPE (exit 3).

func NewValidationError

func NewValidationError(message string) *CLIError

NewValidationError creates a VALIDATION_ERROR (exit 3).

func (*CLIError) Error

func (e *CLIError) Error() string

Error implements the error interface.

func (*CLIError) MarshalJSON

func (e *CLIError) MarshalJSON() ([]byte, error)

MarshalJSON produces {"error": {"code": "...", "message": "...", ...}}.

func (*CLIError) Unwrap

func (e *CLIError) Unwrap() error

Unwrap supports errors.Is and errors.As chains.

func (*CLIError) WithContext

func (e *CLIError) WithContext(ctx map[string]interface{}) *CLIError

WithContext returns the error with the given context map.

func (*CLIError) WithErr

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

WithErr wraps an underlying error for unwrapping.

func (*CLIError) WithSuggestion

func (e *CLIError) WithSuggestion(s string) *CLIError

WithSuggestion returns the error with an actionable suggestion.

type ErrorCode

type ErrorCode string

ErrorCode is a machine-readable string identifying the error category.

const (
	GENERAL_ERROR      ErrorCode = "GENERAL_ERROR"
	AUTH_ERROR         ErrorCode = "AUTH_ERROR"
	VALIDATION_ERROR   ErrorCode = "VALIDATION_ERROR"
	NOT_FOUND          ErrorCode = "NOT_FOUND"
	PERMISSION_DENIED  ErrorCode = "PERMISSION_DENIED"
	RATE_LIMITED       ErrorCode = "RATE_LIMITED"
	INVALID_TRANSITION ErrorCode = "INVALID_TRANSITION"
	MISSING_FIELD      ErrorCode = "MISSING_FIELD"
	UNKNOWN_TYPE       ErrorCode = "UNKNOWN_TYPE"
	AMBIGUOUS_USER     ErrorCode = "AMBIGUOUS_USER"
	NETWORK_ERROR      ErrorCode = "NETWORK_ERROR"
	CONFLICT_ERROR     ErrorCode = "CONFLICT_ERROR"
)

Jump to

Keyboard shortcuts

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