apierr

package
v1.261022.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MPL-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package apierr provides the shared JSON error-response writers for module HTTP handlers, so packages that must avoid importing internal/server can depend on error-response formatting without reintroducing that cycle.

Three wire shapes are in use and the web UI depends on each, so the shapes are kept as separate, explicitly named writers rather than collapsed into one:

Send     {"error": {"message": ..., "type": ...}}   OpenAI-style, for gateway-flavoured endpoints
Message  {"error": "..."}                           bare message
Failure  {"success": false, "error": "..."}         envelope used by management APIs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Failure added in v1.261002.1

func Failure(c *gin.Context, status int, msg string)

Failure writes a {"success": false, "error": "<msg>"} JSON response.

func Message added in v1.261002.1

func Message(c *gin.Context, status int, msg string)

Message writes a {"error": "<msg>"} JSON response.

func Send

func Send(c *gin.Context, status int, err error, errType string)

Send writes a {"error": {"message", "type"}} JSON response.

Types

type Writer added in v1.261002.1

type Writer func(c *gin.Context, status int, msg string)

Writer is the common signature of Message and Failure. Helpers that must report an error in a caller-chosen shape (e.g. bind.JSON) take one.

Jump to

Keyboard shortcuts

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