Help us shape the future of Go! Take the 2026 Go Developer Survey

apierror

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package apierror keeps internal error text out of API responses.

Database, driver and provider errors can carry SQL, schema, constraint or host details. Handlers map the errors a client can act on to fixed messages and pass everything else to Internal (Huma operations) or Log (net/http handlers), which log the error and leave the client with a generic message.

Index

Constants

View Source
const InternalMessage = "internal error"

InternalMessage is the response text for an unexpected error.

Variables

This section is empty.

Functions

func Internal

func Internal(ctx context.Context, logger *slog.Logger, op string, err error) huma.StatusError

Internal logs err like Log and returns a Huma 500 error whose body carries InternalMessage and no error text. Never pass err itself to a huma.Error constructor: Huma copies it into the response's errors list.

func Log

func Log(ctx context.Context, logger *slog.Logger, op string, err error)

Log records err, an unexpected error of the operation op, with logger, or slog.Default() when logger is nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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