errors

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureCorrelationID

func EnsureCorrelationID(envelope *errors.ErrorEnvelope, ctx context.Context) *errors.ErrorEnvelope

EnsureCorrelationID attaches a correlation ID to the envelope using the context when available.

func EnsureEnvelope

func EnsureEnvelope(err error) *errors.ErrorEnvelope

EnsureEnvelope normalizes any error into a gofulmen ErrorEnvelope.

func HTTPStatusFromCode

func HTTPStatusFromCode(code string) int

HTTPStatusFromCode resolves the HTTP status code corresponding to an error code.

func HTTPStatusFromEnvelope

func HTTPStatusFromEnvelope(envelope *errors.ErrorEnvelope) int

HTTPStatusFromEnvelope resolves the HTTP status code corresponding to an error envelope.

func NewConfigInvalidError

func NewConfigInvalidError(message string) *errors.ErrorEnvelope

func NewConflictError

func NewConflictError(message string) *errors.ErrorEnvelope

func NewDataProcessingError

func NewDataProcessingError(message string) *errors.ErrorEnvelope

Application-Specific Errors

func NewDatabaseError

func NewDatabaseError(message string) *errors.ErrorEnvelope

func NewExternalServiceError

func NewExternalServiceError(message string) *errors.ErrorEnvelope

func NewForbiddenError

func NewForbiddenError(message string) *errors.ErrorEnvelope

func NewInternalError

func NewInternalError(message string) *errors.ErrorEnvelope

Server Errors (500-level)

func NewInvalidInputError

func NewInvalidInputError(message string) *errors.ErrorEnvelope

User Errors (400-level)

func NewMethodNotAllowedError

func NewMethodNotAllowedError(message string) *errors.ErrorEnvelope

func NewNotFoundError

func NewNotFoundError(message string) *errors.ErrorEnvelope

func NewTimeoutError

func NewTimeoutError(message string) *errors.ErrorEnvelope

func NewUnauthorizedError

func NewUnauthorizedError(message string) *errors.ErrorEnvelope

func NewValidationError

func NewValidationError(message string) *errors.ErrorEnvelope

func RespondWithEnvelope

func RespondWithEnvelope(w http.ResponseWriter, r *http.Request, envelope *errors.ErrorEnvelope)

RespondWithEnvelope finalizes the provided envelope, logging and emitting metrics.

func RespondWithError

func RespondWithError(w http.ResponseWriter, r *http.Request, err error)

RespondWithError normalizes the supplied error and writes a JSON response.

func ResponseDetails

func ResponseDetails(envelope *errors.ErrorEnvelope) map[string]interface{}

ResponseDetails constructs API-safe details map by merging envelope details and context.

func WrapConfigInvalid

func WrapConfigInvalid(ctx context.Context, err error, message string) *errors.ErrorEnvelope

func WrapConflict

func WrapConflict(ctx context.Context, err error, message string) *errors.ErrorEnvelope

func WrapDataProcessing

func WrapDataProcessing(ctx context.Context, err error, message string) *errors.ErrorEnvelope

func WrapDatabaseError

func WrapDatabaseError(ctx context.Context, err error, message string) *errors.ErrorEnvelope

func WrapExternalService

func WrapExternalService(ctx context.Context, err error, message string) *errors.ErrorEnvelope

func WrapForbidden

func WrapForbidden(ctx context.Context, err error, message string) *errors.ErrorEnvelope

func WrapInternal

func WrapInternal(ctx context.Context, err error, message string) *errors.ErrorEnvelope

func WrapInvalidInput

func WrapInvalidInput(ctx context.Context, err error, message string) *errors.ErrorEnvelope

func WrapNotFound

func WrapNotFound(ctx context.Context, err error, message string) *errors.ErrorEnvelope

func WrapTimeout

func WrapTimeout(ctx context.Context, err error, message string) *errors.ErrorEnvelope

func WrapUnauthorized

func WrapUnauthorized(ctx context.Context, err error, message string) *errors.ErrorEnvelope

func WrapValidationError

func WrapValidationError(ctx context.Context, err error, message string) *errors.ErrorEnvelope

Types

type HTTPErrorDetail

type HTTPErrorDetail struct {
	Code      string                 `json:"code"`
	Message   string                 `json:"message"`
	Details   map[string]interface{} `json:"details,omitempty"`
	RequestID string                 `json:"request_id,omitempty"`
}

HTTPErrorDetail captures the error body returned to callers.

type HTTPErrorResponse

type HTTPErrorResponse struct {
	Error HTTPErrorDetail `json:"error"`
}

HTTPErrorResponse wraps HTTPErrorDetail in the standard envelope structure.

Jump to

Keyboard shortcuts

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