apierr

package
v0.12.21 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package apierr provides error classification and HTTP status mapping for Tumblebug API responses, inspired by pkg.go.dev/k8s.io/apimachinery/pkg/api/errors.

Use Wrap in the resource layer to attach a message to downstream errors, and Code in REST handlers to derive the HTTP status code.

IsNotFound and IsConflict classify errors in priority order: (1) Spider IID pattern — most reliable, set before any CSP call (Spider PR #1623). (2) Message patterns — CSP text Spider proxies as HTTP 500. (3) HTTP status — lowest priority; Spider's status is inconsistent (VPC always 500).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Code

func Code(err error) int

Code maps err to an HTTP status code (404, 409, or 500).

func IsConflict

func IsConflict(err error) bool

IsConflict reports whether err represents a conflict / already-exists condition.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err represents a not-found condition.

func Wrap

func Wrap(err error, message string) error

Wrap attaches message to err, preserving StatusCode and Cause.

Types

type StatusError

type StatusError struct {
	StatusCode int
	Message    string // Tumblebug-level message; empty until set by Wrap.
	Cause      error  // raw Spider / Terrarium / network error.
}

StatusError is the error type used throughout the Tumblebug pipeline. HandleHttpResponse sets StatusCode and Cause; Wrap sets Message. Error() returns "message: cause", or whichever field is non-empty.

func (*StatusError) Error

func (e *StatusError) Error() string

func (*StatusError) Unwrap

func (e *StatusError) Unwrap() error

Unwrap implements the errors unwrap interface.

Jump to

Keyboard shortcuts

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