errors

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitSuccess    = 0 // Success
	ExitGeneral    = 1 // General error
	ExitConfig     = 2 // Configuration error (missing config, invalid tokens)
	ExitAuth       = 3 // Authentication error (invalid/expired tokens)
	ExitRateLimit  = 4 // Rate limit exceeded
	ExitNetwork    = 5 // Network error
	ExitPermission = 6 // Permission denied (missing scopes)
	ExitNotFound   = 7 // Resource not found (channel, user, message)
	ExitTimeout    = 124
)

Exit codes as defined in docs/DESIGN.md section 8.1

Variables

This section is empty.

Functions

func AuthError

func AuthError(msg string, args ...interface{}) error

AuthError creates an authentication-related error.

func ChannelNotFoundError

func ChannelNotFoundError(channel string) error

ChannelNotFoundError creates a specific error for missing channels with helpful hints.

func ClassifySlackError

func ClassifySlackError(err error) int

ClassifySlackError examines a Slack API error and returns an appropriate exit code.

func ConfigError

func ConfigError(msg string, args ...interface{}) error

ConfigError creates a configuration-related error.

func Execute

func Execute(rootCmd *cobra.Command)

Execute runs a cobra command and exits with the appropriate code. This should be used in main.go to ensure proper exit codes.

func HandleCommandError

func HandleCommandError(cmd *cobra.Command, err error) error

HandleCommandError processes an error from a command and sets the appropriate exit code. It should be called in the RunE function of cobra commands.

func IsMissingScopeError

func IsMissingScopeError(err error) bool

IsMissingScopeError checks if an error is due to missing OAuth scopes.

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError checks if an error is a not-found error.

func MissingScopeError

func MissingScopeError(operation string, requiredScopes ...string) error

MissingScopeError creates a user-friendly error for missing OAuth scopes.

func NetworkError

func NetworkError(msg string, args ...interface{}) error

NetworkError creates a network-related error.

func NotFoundError

func NotFoundError(resourceType, identifier string, hint string) error

NotFoundError creates a user-friendly error for missing resources.

func RateLimitError

func RateLimitError(retryAfter string) error

RateLimitError creates a rate limit error with retry information.

func TimeoutError added in v0.1.9

func TimeoutError(msg string, args ...interface{}) error

TimeoutError creates an error for commands that intentionally waited and timed out.

func UserNotFoundError

func UserNotFoundError(user string) error

UserNotFoundError creates a specific error for missing users with helpful hints.

Types

type ErrorWithExitCode

type ErrorWithExitCode struct {
	Err      error
	ExitCode int
}

ErrorWithExitCode wraps an error with a specific exit code.

func NewErrorWithCode

func NewErrorWithCode(code int, format string, args ...interface{}) *ErrorWithExitCode

NewErrorWithCode creates an error with a specific exit code.

func WrapWithCode

func WrapWithCode(code int, err error, format string, args ...interface{}) *ErrorWithExitCode

WrapWithCode wraps an existing error with an exit code.

func (*ErrorWithExitCode) Error

func (e *ErrorWithExitCode) Error() string

func (*ErrorWithExitCode) Unwrap

func (e *ErrorWithExitCode) Unwrap() error

Jump to

Keyboard shortcuts

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