errfmt

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package errfmt defines the stable exit codes and typed errors shared by every store CLI built on vtexkit.

The codes are a published contract: agents and scripts branch on them, so a number may never change meaning across releases. Codes 7 and 8 are the only transient ones — everything else means fail fast.

Index

Constants

View Source
const (
	ExitOK        = 0
	ExitError     = 1
	ExitUsage     = 2
	ExitEmpty     = 3
	ExitAuth      = 4
	ExitNotFound  = 5
	ExitForbidden = 6
	ExitRateLimit = 7
	ExitRetryable = 8
	// ExitDomain reports that a store business rule refused the operation.
	// zonasul v0.5.0 published this code as "cart below R$100 minimum";
	// the number is preserved but the meaning is generalized, because a
	// minimum order is meaningless for a store that has none.
	ExitDomain = 9
	ExitConfig = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Detail  string `json:"detail,omitempty"`
}

func Auth

func Auth(msg string) *Error

func Config

func Config(msg string) *Error

func Domain

func Domain(msg string) *Error

Domain reports a store business rule refusing the operation: an order below the store minimum, an unavailable item, a closed store. The message carries the specific rule so a caller knows what happened; the code stays stable so an agent can branch on it.

func Empty

func Empty() *Error

func Forbidden

func Forbidden(msg string) *Error

func New

func New(code int, msg string) *Error

func NotFound

func NotFound(msg string) *Error

func RateLimit

func RateLimit() *Error

func Retryable

func Retryable(msg string) *Error

func Usage

func Usage(msg string) *Error

func Wrap

func Wrap(code int, msg string, err error) *Error

func (*Error) Error

func (e *Error) Error() string

type ExitCodeEntry

type ExitCodeEntry struct {
	Code        int    `json:"code"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Transient   bool   `json:"transient"`
}

func ExitCodeTable

func ExitCodeTable() []ExitCodeEntry

ExitCodeTable is the machine-readable exit code reference, exposed by every CLI as `<store> exit-codes --json`. Entries are index-aligned to their codes.

Jump to

Keyboard shortcuts

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