apierror

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package apierror renders non-2xx API responses into error messages that are actually useful for debugging. One implementation shared by every service command tree (snapdb, langsync, ...), so the format stays identical across the CLI:

  • always includes the request method + URL, so users can tell whether they're pointing at prod or a local backend;
  • prefers the server's typed JSON error body when one matched;
  • otherwise falls back to the raw response body (truncated), which is the only thing that surfaces 5xx errors from proxies and LBs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(service string, resp *http.Response, body []byte, typed ...*Typed) error

Format builds the standard "service METHOD URL: detail" error. The first non-nil typed body wins; with none, the raw body is used.

Types

type Typed

type Typed struct {
	Msg  string
	Type string
}

Typed is the service-agnostic view of a typed API error body. Each service package converts its generated ResponseAPIError into this.

Jump to

Keyboard shortcuts

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