apierr

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package apierr is the shared HTTP response envelope: the Tinybird-compatible error shape (ADR 0012) and JSON write helpers. Centralized so every handler — core routes and the /v0/sql, /v0/metrics, etc. add-ons — emits an identical structure and status mapping.

Index

Constants

View Source
const DBExceptionHeader = "X-DB-Exception-Code"

DBExceptionHeader passes the ClickHouse exception code through to the client (ADR 0012). Set it from a clickhouse.CHError when one is available.

Variables

This section is empty.

Functions

func EncodeJSON

func EncodeJSON(w http.ResponseWriter, status int, v any)

EncodeJSON marshals v and sends it with the given status.

func WriteError

func WriteError(w http.ResponseWriter, status int, msg string)

WriteError sends {"error": msg} with the given status (ADR 0012).

func WriteErrorWithCode

func WriteErrorWithCode(w http.ResponseWriter, status, dbCode int, msg string)

WriteErrorWithCode is WriteError plus the X-DB-Exception-Code header.

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, raw []byte)

WriteJSON sends a pre-encoded JSON body verbatim (e.g. a ClickHouse response).

func WriteRaw

func WriteRaw(w http.ResponseWriter, status int, contentType string, raw []byte)

WriteRaw sends a pre-encoded body verbatim with an explicit content type — used for alternate pipe output formats (text/csv, application/x-ndjson) where the ClickHouse response is not JSON.

Types

This section is empty.

Jump to

Keyboard shortcuts

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