errors

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ErrCodeAuth       = "AUTH_ERROR"
	ErrCodeConfig     = "CONFIG_ERROR"
	ErrCodeValidation = "VALIDATION_ERROR"
	ErrCodeNetwork    = "NETWORK_ERROR"
	ErrCodeAPI        = "API_ERROR"
)

Error codes

Variables

This section is empty.

Functions

func GetExitCode

func GetExitCode(err error) int

GetExitCode returns the exit code for err. A printed result's error exits with its own code, and a CLI error with its own code maps by that code. Otherwise an API error, bare or wrapped, maps by its HTTP status, and a network failure or timeout exits 7. Anything else exits 1.

func IsAPIUnreachable added in v0.3.0

func IsAPIUnreachable(err error) bool

IsAPIUnreachable reports whether err is a failure to reach the API: the SDK's network error or a failed HTTP request, such as a refused connection, a failed DNS lookup or a timeout. A failure to reach another server, such as the SMTP server of smtp send, is not one.

func IsRetryable added in v0.3.0

func IsRetryable(err error) bool

IsRetryable reports whether a request that failed with err may succeed when sent again: the API answered 429 or a 5xx status, or said an earlier request with the same idempotency key is still in progress, or could not be reached for a reason other than its TLS certificate.

Types

type CLIError

type CLIError struct {
	Code    string
	Message string
	Cause   error
}

CLIError represents a CLI-specific error

func NewAPIError

func NewAPIError(message string, cause error) *CLIError

NewAPIError creates an API error

func NewAuthError

func NewAuthError(message string, cause error) *CLIError

NewAuthError creates an authentication error

func NewConfigError

func NewConfigError(message string, cause error) *CLIError

NewConfigError creates a configuration error

func NewNetworkError

func NewNetworkError(message string, cause error) *CLIError

NewNetworkError creates the error of a connection that failed, which exits 7

func NewValidationError

func NewValidationError(message string, cause error) *CLIError

NewValidationError creates a validation error

func (*CLIError) Error

func (e *CLIError) Error() string

func (*CLIError) Unwrap

func (e *CLIError) Unwrap() error

type ItemsFailedError added in v0.3.0

type ItemsFailedError struct {
	Failed int
	Total  int
	// Noun names the items, such as "contacts" or "addresses".
	Noun string
}

ItemsFailedError reports that a command printed its whole result but some of the items in it failed. The command exits 1; the result already shows which items failed and why.

func NewItemsFailedError added in v0.3.0

func NewItemsFailedError(failed, total int, noun string) *ItemsFailedError

NewItemsFailedError creates the error for a result in which failed of total items failed.

func (*ItemsFailedError) Error added in v0.3.0

func (e *ItemsFailedError) Error() string

type ResultPrintedError added in v0.3.0

type ResultPrintedError struct {
	Message string
	Code    int
}

ResultPrintedError reports a failure that the command's printed result already shows, such as a credentials check that did not pass. The command exits with Code, and outside JSON output Message is printed to stderr.

func NewResultPrintedError added in v0.3.0

func NewResultPrintedError(message string, code int) *ResultPrintedError

NewResultPrintedError creates the error for a printed result that shows a failure; the command exits with code.

func (*ResultPrintedError) Error added in v0.3.0

func (e *ResultPrintedError) Error() string

type UnreadableResponseError added in v0.3.0

type UnreadableResponseError struct {
	Body   []byte // the response body
	Reason string // why the body could not be read
}

UnreadableResponseError reports a successful API response whose body the CLI could not read as the result it expects. The command exits 1; JSON output prints Body as it is.

func NewUnreadableResponseError added in v0.3.0

func NewUnreadableResponseError(body []byte, reason string) *UnreadableResponseError

NewUnreadableResponseError creates the error for a successful response whose body could not be read, and why.

func (*UnreadableResponseError) Error added in v0.3.0

func (e *UnreadableResponseError) Error() string

Jump to

Keyboard shortcuts

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