faults

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Is

func Is(err error, target error) bool

Types

type ErrAttr

type ErrAttr struct {
	Code     ErrCode
	Messages []LangPackage
}

type ErrCode

type ErrCode int

type Error

type Error struct {
	// contains filtered or unexported fields
}
var (
	ErrBadRequest              Error
	ErrUnauthorized            Error
	ErrPaymentRequired         Error
	ErrForbidden               Error
	ErrNotFound                Error
	ErrMethodNotAllowed        Error
	ErrNotAcceptable           Error
	ErrProxyAuthRequired       Error
	ErrRequestTimeout          Error
	ErrConflict                Error
	ErrGone                    Error
	ErrLengthRequired          Error
	ErrPreconditionFailed      Error
	ErrPayloadTooLarge         Error
	ErrURITooLong              Error
	ErrUnsupportedMediaType    Error
	ErrRangeNotSatisfiable     Error
	ErrExpectationFailed       Error
	ErrIMTeapot                Error
	ErrMisdirectedRequest      Error
	ErrUnprocessableEntity     Error
	ErrLocked                  Error
	ErrFailedDependency        Error
	ErrTooEarly                Error
	ErrUpgradeRequired         Error
	ErrPreconditionRequired    Error
	ErrTooManyRequests         Error
	ErrInternalServerError     Error
	ErrNotImplemented          Error
	ErrBadGateway              Error
	ErrBadGatewayf             Error
	ErrServiceUnavailable      Error
	ErrGatewayTimeout          Error
	ErrUnprocessable           Error
	ErrHTTPVersionNotSupported Error
	ErrInsufficientStorage     Error

	ErrRequired               Error
	ErrBelowMinimum           Error
	ErrAboveMaximum           Error
	ErrMustBeEmail            Error
	ErrMustBeDigit            Error
	ErrMustBeAlphanum         Error
	ErrMustBeAlphabet         Error
	ErrLengthBelowMinimum     Error
	ErrLengthAboveMaximum     Error
	ErrInvalidDateFormat      Error
	ErrInvalidDatetimeFormat  Error
	ErrUnsupportedDataType    Error
	ErrInvalidParameter       Error
	ErrMustBeName             Error
	ErrMustBeText             Error
	ErrMustBeOneOf            Error
	ErrUnsupportedContentType Error
	ErrCannotBeNull           Error
	ErrTypeMismatch           Error
	ErrInvalidNumericFormat   Error
	ErrInvalidFloatNumber     Error
	ErrInvalidIntegerNumber   Error
)

func New

func New(err error, attr *ErrAttr, args ...any) Error

func (Error) Code

func (err Error) Code() ErrCode

func (Error) Error

func (err Error) Error() string

func (Error) LocalizedError

func (err Error) LocalizedError(tag LanguageTag) string

func (Error) MarshalJSON

func (e Error) MarshalJSON() ([]byte, error)

MarshalJSON returns the error as a JSON string

func (Error) Render

func (err Error) Render(args ...any) Error

func (Error) SetLocaleMessage

func (err Error) SetLocaleMessage(tag LanguageTag, message string)

func (Error) SupportedTags

func (err Error) SupportedTags() (tags []LanguageTag)

type Errors

type Errors map[string]error

func (Errors) Error

func (errs Errors) Error() string

func (Errors) LocalizedError

func (errs Errors) LocalizedError(tag LanguageTag) map[string]any

type LangPackage

type LangPackage struct {
	Tag     LanguageTag
	Message string
}

type LanguageTag

type LanguageTag string
var (
	Bahasa  LanguageTag = LanguageTag(language.Indonesian.String())
	English LanguageTag = LanguageTag(language.English.String())

	DefaultLocale = English
)

type YamlPackage

type YamlPackage struct {
	Errors   map[string]map[LanguageTag]string `yaml:"errors"`
	Packages map[string]ErrAttr
}

func NewYamlPackage

func NewYamlPackage() YamlPackage

func (*YamlPackage) LoadBytes added in v0.1.9

func (raw *YamlPackage) LoadBytes(yamlBytes []byte) error

func (*YamlPackage) LoadYaml

func (raw *YamlPackage) LoadYaml(filename string) error

func (YamlPackage) NewError

func (yml YamlPackage) NewError(key string) Error

Jump to

Keyboard shortcuts

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