Documentation
¶
Overview ¶
Package apierr provides a standardised error response format for the QubicDB HTTP API.
Every error response returned by the API uses the same JSON envelope:
{
"ok": false,
"error": "human-readable description",
"code": "MACHINE_READABLE_CODE",
"status": 400
}
This makes error handling predictable for all API consumers — clients can branch on the "code" field for programmatic handling and show the "error" field to humans.
Index ¶
- Constants
- func BadRequest(w http.ResponseWriter, code, msg string)
- func Conflict(w http.ResponseWriter, code, msg string)
- func IndexIDRequired(w http.ResponseWriter)
- func Internal(w http.ResponseWriter, msg string)
- func InvalidJSON(w http.ResponseWriter)
- func MethodNotAllowed(w http.ResponseWriter)
- func NeuronIDRequired(w http.ResponseWriter)
- func NotFound(w http.ResponseWriter, code, msg string)
- func PayloadTooLarge(w http.ResponseWriter, msg string)
- func QueryRequired(w http.ResponseWriter)
- func TooManyRequests(w http.ResponseWriter, msg string)
- func UUIDRequired(w http.ResponseWriter)
- func Unauthorized(w http.ResponseWriter, msg string)
- func Write(w http.ResponseWriter, status int, code, message string)
- type Response
Constants ¶
const ( // General CodeBadRequest = "BAD_REQUEST" CodeInvalidJSON = "INVALID_JSON" CodeInvalidContent = "INVALID_CONTENT" CodePayloadTooLarge = "PAYLOAD_TOO_LARGE" CodeMethodNotAllowed = "METHOD_NOT_ALLOWED" CodeNotFound = "NOT_FOUND" CodeInternalError = "INTERNAL_ERROR" CodeRateLimited = "RATE_LIMITED" CodeConflict = "CONFLICT" CodeMutationDisabled = "MUTATION_DISABLED" // Brain / Neuron domain CodeIndexIDRequired = "INDEX_ID_REQUIRED" CodeNeuronIDRequired = "NEURON_ID_REQUIRED" CodeNeuronNotFound = "NEURON_NOT_FOUND" CodeQueryRequired = "QUERY_REQUIRED" CodeUUIDRequired = "UUID_REQUIRED" // Registry domain CodeUUIDNotRegistered = "UUID_NOT_REGISTERED" CodeUUIDNotFound = "UUID_NOT_FOUND" CodeUUIDConflict = "UUID_CONFLICT" )
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
func BadRequest(w http.ResponseWriter, code, msg string)
BadRequest writes a 400 response with the given code and message.
func Conflict ¶
func Conflict(w http.ResponseWriter, code, msg string)
Conflict writes a 409 response.
func IndexIDRequired ¶
func IndexIDRequired(w http.ResponseWriter)
IndexIDRequired writes a 400 response when X-Index-ID is missing.
func InvalidJSON ¶
func InvalidJSON(w http.ResponseWriter)
InvalidJSON writes a 400 response for malformed request bodies.
func MethodNotAllowed ¶
func MethodNotAllowed(w http.ResponseWriter)
MethodNotAllowed writes a 405 response.
func NeuronIDRequired ¶
func NeuronIDRequired(w http.ResponseWriter)
NeuronIDRequired writes a 400 response when a neuron ID is missing.
func NotFound ¶
func NotFound(w http.ResponseWriter, code, msg string)
NotFound writes a 404 response.
func PayloadTooLarge ¶
func PayloadTooLarge(w http.ResponseWriter, msg string)
PayloadTooLarge writes a 413 response when body/content exceeds configured bounds.
func QueryRequired ¶
func QueryRequired(w http.ResponseWriter)
QueryRequired writes a 400 response when a search query is empty.
func TooManyRequests ¶
func TooManyRequests(w http.ResponseWriter, msg string)
TooManyRequests writes a 429 response.
func UUIDRequired ¶
func UUIDRequired(w http.ResponseWriter)
UUIDRequired writes a 400 response when a UUID is missing.
func Unauthorized ¶
func Unauthorized(w http.ResponseWriter, msg string)
Unauthorized writes a 401 response.