Documentation
¶
Index ¶
- Variables
- func ExitCode(err error) int
- func NewAPI(message string, opts ...Option) error
- func NewAuth(message string, opts ...Option) error
- func NewDiscovery(message string, opts ...Option) error
- func NewInternal(message string, opts ...Option) error
- func NewValidation(message string, opts ...Option) error
- func PrintHuman(w io.Writer, err error) error
- func PrintJSON(w io.Writer, err error) error
- func ResourceName(name string) error
- func SafePath(path string) error
- type Category
- type Error
- type Option
- func WithActions(actions ...string) Option
- func WithCause(err error) Option
- func WithHint(hint string) Option
- func WithOperation(operation string) Option
- func WithRPCCode(code int) Option
- func WithRPCData(data json.RawMessage) Option
- func WithReason(reason string) Option
- func WithRetryable(retryable bool) Option
- func WithServerKey(serverKey string) Option
- func WithSnapshot(path string) Option
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidResourceName = stderrors.New("invalid resource name") ErrUnsafePath = stderrors.New("unsafe path detected") )
Functions ¶
func NewDiscovery ¶
NewDiscovery returns a discovery-category error.
func NewInternal ¶
NewInternal returns an internal-category error.
func NewValidation ¶
NewValidation returns a validation-category error.
func PrintHuman ¶
PrintHuman writes a concise human-readable error rendering.
func ResourceName ¶
Types ¶
type Category ¶
type Category string
Category represents a stable error class with a documented exit code.
type Error ¶
type Error struct {
Category Category
Message string
Operation string
ServerKey string
Retryable bool
Reason string
Hint string
Actions []string
Snapshot string
RPCCode int `json:"rpc_code,omitempty"`
RPCData json.RawMessage `json:"rpc_data,omitempty"`
Cause error `json:"-"`
}
Error is the structured repository-local error model for the Go rewrite.
type Option ¶
type Option func(*Error)
Option mutates a structured error before it is returned.
func WithActions ¶
WithActions records suggested next actions for recovery.
func WithOperation ¶
WithOperation records the operation that failed.
func WithRPCCode ¶
WithRPCCode records the original JSON-RPC error code.
func WithRPCData ¶
func WithRPCData(data json.RawMessage) Option
WithRPCData records the original JSON-RPC error data payload.
func WithReason ¶
WithReason records a stable machine-readable failure reason.
func WithRetryable ¶
WithRetryable marks whether the error can be retried safely.
func WithServerKey ¶
WithServerKey records the server identifier associated with the failure.
func WithSnapshot ¶
WithSnapshot records the recovery snapshot path associated with the failure.