Documentation ¶
Index ¶
- Constants
- type Config
- type ContextKey
- type DefaultError
- type DefaultMessageCatalog
- func (dmc *DefaultMessageCatalog) GetErrorWithCtx(ctx context.Context, msgCode int, msgParams ...interface{}) error
- func (dmc *DefaultMessageCatalog) GetMessageWithCtx(ctx context.Context, msgCode int, msgParams ...interface{}) *Message
- func (dmc *DefaultMessageCatalog) LoadMessages(lang string, messages []RawMessage) error
- func (dmc *DefaultMessageCatalog) WrapErrorWithCtx(ctx context.Context, err error, msgCode int, msgParams ...interface{}) error
- type Error
- type Message
- type MessageCatalog
- type MessageParams
- type Messages
- type RawMessage
Constants ¶
View Source
const MessageCatalogNotFound = "Unexpected error in message catalog, language [%s] not found. %s"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { ResourcePath string CtxLanguageKey ContextKey }
type ContextKey ¶
type ContextKey string
type DefaultError ¶
type DefaultError struct {
// contains filtered or unexported fields
}
func (DefaultError) Error ¶
func (ce DefaultError) Error() string
func (*DefaultError) ErrorCode ¶
func (ce *DefaultError) ErrorCode() int
func (*DefaultError) GetLongMessage ¶
func (ce *DefaultError) GetLongMessage() string
func (*DefaultError) GetShortMessage ¶
func (ce *DefaultError) GetShortMessage() string
func (*DefaultError) Unwrap ¶
func (ce *DefaultError) Unwrap() error
type DefaultMessageCatalog ¶
type DefaultMessageCatalog struct {
// contains filtered or unexported fields
}
func (*DefaultMessageCatalog) GetErrorWithCtx ¶
func (dmc *DefaultMessageCatalog) GetErrorWithCtx(ctx context.Context, msgCode int, msgParams ...interface{}) error
func (*DefaultMessageCatalog) GetMessageWithCtx ¶
func (dmc *DefaultMessageCatalog) GetMessageWithCtx(ctx context.Context, msgCode int, msgParams ...interface{}) *Message
func (*DefaultMessageCatalog) LoadMessages ¶
func (dmc *DefaultMessageCatalog) LoadMessages(lang string, messages []RawMessage) error
func (*DefaultMessageCatalog) WrapErrorWithCtx ¶
type MessageCatalog ¶
type MessageCatalog interface { // Allows to load more messages (9000 - 9999 - reserved to system messages) LoadMessages(lang string, messages []RawMessage) error GetMessageWithCtx(ctx context.Context, msgCode int, msgParams ...interface{}) *Message WrapErrorWithCtx(ctx context.Context, err error, msgCode int, msgParams ...interface{}) error GetErrorWithCtx(ctx context.Context, msgCode int, msgParams ...interface{}) error }
func NewMessageCatalog ¶
func NewMessageCatalog(cfg Config) (MessageCatalog, error)
type MessageParams ¶
type MessageParams struct {
Params map[string]interface{}
}
type Messages ¶
type Messages struct { Group int `yaml:"group"` Default RawMessage `yaml:"default"` Set map[int]RawMessage `yaml:"set"` }
type RawMessage ¶
Click to show internal directories.
Click to hide internal directories.