zeerr

package
v0.0.21-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithLocale

func ContextWithLocale(ctx context.Context, lang language.Tag) context.Context

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error represents a standardized error.

func NewError

func NewError(
	ctx context.Context,
	localizer Localizer,
	id string,
	httpCode int,
	grpcCode codes.Code,
	arguments map[string]any,
) *Error

NewError creates a new Error.

func RestoreError

func RestoreError(
	id string,
	httpCode int,
	grpcCode codes.Code,
	arguments map[string]any,
	message string,
	causes []*Error,
) *Error

func (Error) Arguments

func (e Error) Arguments() map[string]any

func (Error) Causes

func (e Error) Causes() []*Error

func (*Error) Error

func (e *Error) Error() string

func (Error) GRPCCode

func (e Error) GRPCCode() codes.Code

func (Error) HTTPCode

func (e Error) HTTPCode() int

func (Error) ID

func (e Error) ID() string

func (Error) InternalErr

func (e Error) InternalErr() error

func (Error) Message

func (e Error) Message() string

func (*Error) WithCauses

func (e *Error) WithCauses(causes ...*Error) *Error

func (*Error) WithInternalError

func (e *Error) WithInternalError(err error) *Error

type LocaleCtxKeyType

type LocaleCtxKeyType struct{}

type Localizer

type Localizer interface {
	// LocalizeMessage localizes error's message.
	LocalizeMessage(id string, lang language.Tag, args map[string]any) string
}

Localizer is responsible for localizing public and internal error messages.

Jump to

Keyboard shortcuts

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