util

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeAuthError            = "auth_error"
	CodeValidationError      = "validation_error"
	CodeNotFound             = "not_found"
	CodeRateLimited          = "rate_limited"
	CodeAPIError             = "api_error"
	CodeConfirmationRequired = "confirmation_required"
	CodeConfirmationInvalid  = "confirmation_invalid"
	CodeIdempotencyConflict  = "idempotency_conflict"
	CodeNetworkError         = "network_error"
	CodeUnknownError         = "unknown_error"
)

Variables

This section is empty.

Functions

func FormatUSDMinor

func FormatUSDMinor(amount int64) string

func MaskAccountNumber

func MaskAccountNumber(value string) string

func MaskLast4

func MaskLast4(value string) string

func NewID

func NewID(prefix string) string

func RFC3339OrEmpty

func RFC3339OrEmpty(t time.Time) string

Types

type Envelope

type Envelope struct {
	OK        bool         `json:"ok"`
	RequestID string       `json:"request_id,omitempty"`
	Data      any          `json:"data,omitempty"`
	Error     *ErrorDetail `json:"error,omitempty"`
}

func Fail

func Fail(err *ErrorDetail, requestID string) Envelope

func Ok

func Ok(data any, requestID string) Envelope

type ErrorDetail

type ErrorDetail struct {
	Code      string         `json:"code"`
	Message   string         `json:"message"`
	Details   map[string]any `json:"details,omitempty"`
	Fields    []FieldError   `json:"fields,omitempty"`
	Retryable bool           `json:"retryable,omitempty"`
}

func NewError

func NewError(code, message string, details map[string]any, retryable bool) *ErrorDetail

func (*ErrorDetail) Error

func (e *ErrorDetail) Error() string

type FieldError

type FieldError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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