util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParseRequestBody     = errors.New("failed to parse request body").WithCode("ERR_PARSE_REQUEST_BODY").WithKind(errors.KindInvalidInput)
	ErrMissingAccountID     = errors.New("missing account id parameter").WithCode("ERR_MISSING_ACCOUNT_ID").WithKind(errors.KindInvalidInput)
	ErrMissingPhaseID       = errors.New("missing phase id parameter").WithCode("ERR_MISSING_PHASE_ID").WithKind(errors.KindInvalidInput)
	ErrMissingJourneyID     = errors.New("missing journey id parameter").WithCode("ERR_MISSING_JOURNEY_ID").WithKind(errors.KindInvalidInput)
	ErrInvalidAccountID     = errors.New("invalid account id parameter").WithCode("ERR_INVALID_ACCOUNT_ID").WithKind(errors.KindInvalidInput)
	ErrMissingCustomerID    = errors.New("missing customer id parameter").WithCode("ERR_MISSING_CUSTOMER_ID").WithKind(errors.KindInvalidInput)
	ErrMissingCorrelationID = errors.New("missing correlation id parameter").WithCode("ERR_MISSING_CORRELATION_ID").WithKind(errors.KindInvalidInput)

	ErrInvalidCountryCode = errors.New("invalid country code parameter").WithCode("ERR_INVALID_COUNTRY_CODE").WithKind(errors.KindInvalidInput)
	ErrInvalidStateCode   = errors.New("invalid state code parameter").WithCode("ERR_INVALID_STATE_CODE").WithKind(errors.KindInvalidInput)
)

Functions

func WriteError

func WriteError(ctx context.Context, rw http.ResponseWriter, err error)

func WriteResponse

func WriteResponse(rw http.ResponseWriter, status int, response any)

Types

type APIError

type APIError struct {
	Code      string         `example:"ERR_SOMETHING_WENT_WRONG" json:"code"`
	Message   string         `example:"Something went wrong"     json:"message"`
	Retryable bool           `example:"true"                     json:"retryable"`
	Details   map[string]any `json:"details,omitempty"`
}

func NewAPIError

func NewAPIError(err error) *APIError

func (*APIError) Error

func (e *APIError) Error() string

Jump to

Keyboard shortcuts

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