errcat

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package errcat holds the canonical catalogue of reserved HTTP error categories. It is a leaf below the parser (which rejects an unknown category), codegen (which emits each category's HTTP status + default message), and the LSP (which validates and offers them as completions), so a new category is added in exactly ONE place instead of four. Source: the project README §"Error categories".

Index

Constants

This section is empty.

Variables

View Source
var Categories = []Category{
	{"BadRequest", 400, "Bad request"},
	{"Unauthorized", 401, "Unauthorized"},
	{"PaymentRequired", 402, "Payment required"},
	{"Forbidden", 403, "Forbidden"},
	{"NotFound", 404, "Not found"},
	{"MethodNotAllowed", 405, "Method not allowed"},
	{"NotAcceptable", 406, "Not acceptable"},
	{"Conflict", 409, "Conflict"},
	{"Gone", 410, "Resource gone"},
	{"LengthRequired", 411, "Length required"},
	{"PreconditionFailed", 412, "Precondition failed"},
	{"PayloadTooLarge", 413, "Payload too large"},
	{"UnsupportedMediaType", 415, "Unsupported media type"},
	{"UnprocessableEntity", 422, "Unprocessable entity"},
	{"Locked", 423, "Resource locked"},
	{"TooManyRequests", 429, "Too many requests"},
	{"Internal", 500, "Internal server error"},
	{"NotImplemented", 501, "Not implemented"},
	{"BadGateway", 502, "Bad gateway"},
	{"ServiceUnavailable", 503, "Service unavailable"},
	{"GatewayTimeout", 504, "Gateway timeout"},
}

Categories is the canonical catalogue in status order. The LSP renders `error <cursor>` completions in this order.

Functions

func IsCategory

func IsCategory(name string) bool

IsCategory reports whether name is a reserved error category.

func Message

func Message(name string) string

Message returns the default human-readable message for a category, or "" if unknown.

func Status

func Status(name string) int

Status returns the HTTP status code for a category, or 0 if unknown.

Types

type Category

type Category struct {
	Name    string
	Status  int
	Message string
}

Category is one reserved error category: its DSL name, HTTP status code, and the default human-readable message codegen uses for the runtime Message.

Jump to

Keyboard shortcuts

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