Documentation
¶
Index ¶
Constants ¶
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 ¶
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
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
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 ¶
CLIError represents a CLI-specific error
func NewAPIError ¶
NewAPIError creates an API error
func NewAuthError ¶
NewAuthError creates an authentication error
func NewConfigError ¶
NewConfigError creates a configuration error
func NewNetworkError ¶
NewNetworkError creates the error of a connection that failed, which exits 7
func NewValidationError ¶
NewValidationError creates a validation 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
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