Documentation ¶
Overview ¶
Package i18nerr implements errors with internationalization using gotext
Index ¶
- func TranslatedInner(inner error) (string, bool)
- type Error
- func New(key message.Reference) *Error
- func NewInternal(disp string) *Error
- func NewInternalf(disp string, args ...interface{}) *Error
- func Newf(key message.Reference, args ...interface{}) *Error
- func Wrap(err error, key message.Reference) *Error
- func WrapInternal(err error, disp string) *Error
- func WrapInternalf(err error, disp string, args ...interface{}) *Error
- func Wrapf(err error, key message.Reference, args ...interface{}) *Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TranslatedInner ¶
TranslatedInner defines errors that are used as inner causes but are still translated because they can happen frequently
Types ¶
type Error ¶
type Error struct { Misc bool // contains filtered or unexported fields }
Error wraps an actual error with the translation key This translation key is later used to lookup translation The inner error always consists of the translation key and some formatting
func NewInternal ¶
NewInternal creates an internal localised error from a display string
func NewInternalf ¶
NewInternalf creates an internal localised error from a display string and arguments
func Newf ¶
Newf creates a new i18n error using a message reference and arguments. It formats this with fmt.Errorf
func Wrap ¶
Wrap creates a new i18n error using an error to be wrapped 'err' and a prefix message reference 'key'. It formats this with fmt.Errorf
func WrapInternal ¶
WrapInternal wraps an error and a display string into a localised internal error
func WrapInternalf ¶
WrapInternalf wraps an error and a display string with args into a localised internal error
func Wrapf ¶
Wrapf creates a new i18n error using an error to be wrapped 'err' and a prefix message reference 'key' with format arguments 'args'. It formats this with fmt.Errorf
func (*Error) Error ¶
Error gets the error string it does this by simply forwarding the error method from the actual inner error
func (*Error) Translations ¶
Translations returns all the translations for the error including the source translation (english)