errors

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCloudError

func ParseCloudError(raw string) (code string, message string, requestID string)

func WithActions

func WithActions(source error, actions []Action) error

func WithDetails

func WithDetails(source error, options ...Option) error

Types

type Action

type Action struct {
	RequestID  string `json:"request_id,omitempty"`
	ActionName string `json:"action_name"`
	Code       string `json:"code,omitempty"`
	Message    string `json:"message,omitempty"`
}

func ActionFromError

func ActionFromError(actionName string, err error) Action

type AppError

type AppError struct {
	// contains filtered or unexported fields
}

func Client

func Client(code, message string, options ...Option) *AppError

func NotFound

func NotFound(code, message string, options ...Option) *AppError

func Service

func Service(code, message string, retryable bool, options ...Option) *AppError

func Timeout

func Timeout(code, message string, options ...Option) *AppError

func (*AppError) Actions

func (e *AppError) Actions() []Action

func (*AppError) Error

func (e *AppError) Error() string

func (*AppError) ExitCode

func (e *AppError) ExitCode() int

func (*AppError) Payload

func (e *AppError) Payload() ErrorPayload

type Category

type Category string
const (
	CategoryClient   Category = "client"
	CategoryService  Category = "service"
	CategoryTimeout  Category = "timeout"
	CategoryNotFound Category = "not_found"
)

type ErrorPayload

type ErrorPayload struct {
	Kind            string   `json:"kind"`
	Code            string   `json:"code"`
	Message         string   `json:"message"`
	Retryable       bool     `json:"retryable"`
	Suggestion      string   `json:"suggestion,omitempty"`
	SuggestedAction string   `json:"suggested_action,omitempty"`
	Detail          string   `json:"detail,omitempty"`
	Field           string   `json:"field,omitempty"`
	AcceptedValues  []string `json:"accepted_values,omitempty"`
	CurrentState    string   `json:"current_state,omitempty"`
	ExpectedStates  []string `json:"expected_states,omitempty"`
}

type Option

type Option func(*AppError)

func WithAcceptedValues

func WithAcceptedValues(values ...string) Option

func WithActionsOption

func WithActionsOption(actions ...Action) Option

func WithCurrentState

func WithCurrentState(state string) Option

func WithDetail added in v0.1.2

func WithDetail(detail string) Option

func WithExpectedStates

func WithExpectedStates(states ...string) Option

func WithField

func WithField(field string) Option

func WithRawCause

func WithRawCause(code, message string) Option

func WithRequestID

func WithRequestID(requestID string) Option

func WithSuggestedAction

func WithSuggestedAction(action string) Option

func WithSuggestion

func WithSuggestion(suggestion string) Option

Jump to

Keyboard shortcuts

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