halt

package
v0.0.0-...-3b96a7a Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExtraKeyMessage = "message"
)

Variables

This section is empty.

Functions

func Error

func Error(err error, opts ...Option)

Error panic with New

func ExtrasFromError

func ExtrasFromError(err error) (m map[string]any)

ExtrasFromError extract extras from previous created [HaltError]

func New

func New(err error, opts ...Option) error

New create a new [HaltError]

func StatusCodeFromError

func StatusCodeFromError(err error) int

StatusCodeFromError get status code from previous created [HaltError]

func String

func String(s string, opts ...Option)

String panic with New and errors.New

Types

type Option

type Option func(h *haltError)

Option configuration function for [HaltError]

func WithBadRequest

func WithBadRequest() Option

WithBadRequest alias to WithStatusCode with http.StatusBadRequest

func WithExtra

func WithExtra(k string, v any) Option

WithExtra a Option setting extras with a key-value

func WithExtras

func WithExtras(m map[string]any) Option

WithExtras a Option setting extras with key-values

func WithMessage

func WithMessage(m string) Option

WithMessage a Option overriding message key

func WithStatusCode

func WithStatusCode(code int) Option

WithStatusCode a Option setting status code

Jump to

Keyboard shortcuts

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