except

package
v1.6.9 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(cond interface{}, code int, msg any, args ...interface{}) error

Assert asserts that the condition is true if the condition is false, it panics with the message

func AssertContains

func AssertContains[T comparable](v T, a []T, code int, msg any, args ...interface{}) error

Contains asserts that the value is in the slice if the value is not in the slice, it panics with the message

func AssertContainsFunc

func AssertContainsFunc[T any](a []T, f func(T) (in bool), code int, msg any, args ...interface{}) error

ContainsFunc asserts that the value is in the slice if the value is not in the slice, it panics with the message

func AssertEqual

func AssertEqual[T comparable](a, b T, code int, msg any, args ...interface{}) error

Equal asserts that the two values are equal if the two values are not equal, it panics with the message

func AssertNil added in v1.6.8

func AssertNil(v any, code int, msg any, args ...interface{}) error

AssertNil asserts that the value is nil if the value is not nil, it panics with the message

func AssertNotNil added in v1.6.8

func AssertNotNil(v any, code int, msg any, args ...interface{}) error

AssertNotNil asserts that the value is not nil if the value is nil, it panics with the message

func Fail

func Fail(code int, msg any, args ...interface{}) (err error)

Types

type HttpError

type HttpError struct {
	Message error
	Code    int
}

func (*HttpError) As

func (e *HttpError) As(target interface{}) bool

func (*HttpError) Error

func (e *HttpError) Error() string

func (*HttpError) Is

func (e *HttpError) Is(other error) bool

func (*HttpError) StatusCode

func (e *HttpError) StatusCode() int

func (*HttpError) Unwrap

func (e *HttpError) Unwrap() error

func (*HttpError) UserMessage

func (e *HttpError) UserMessage() string

type ServerError

type ServerError interface {
	error
	StatusCode() int
	UserMessage() string
}

func GetServerError

func GetServerError(err error) ServerError

func NewServerError

func NewServerError(code int, msg any) ServerError

Jump to

Keyboard shortcuts

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