Documentation ¶
Index ¶
- Variables
- func ErrorMessage(err error) string
- func HasError(err error) bool
- func IsError(err error) bool
- func IsInputError(err error) bool
- func IsInputErrorNonRecursive(err error) bool
- func JoinedErrorMessage(err error) string
- func Set(localeName string) (rerr error)
- func T(translationID string, args ...interface{}) string
- func Tl(translationID, locale string, values ...string) string
- func Tr(translationID string, values ...string) string
- func Ts(translationIDs ...string) []string
- func Tt(translationID string, args ...interface{}) string
- func UnpackError(err error) []error
- type AsError
- type ErrorInput
- type ErrorLocalizer
- type LocalizedError
- func NewError(id string, args ...string) *LocalizedError
- func NewExternalError(id string, args ...string) *LocalizedError
- func NewInputError(id string, args ...string) *LocalizedError
- func WrapError(err error, id string, args ...string) *LocalizedError
- func WrapExternalError(wrapTarget error, id string, args ...string) *LocalizedError
- func WrapInputError(err error, id string, args ...string) *LocalizedError
- func (e *LocalizedError) AddTips(tips ...string)
- func (e *LocalizedError) Error() string
- func (e *LocalizedError) ErrorTips() []string
- func (e *LocalizedError) ExternalError() bool
- func (e *LocalizedError) InputError() bool
- func (e *LocalizedError) LocaleError() string
- func (e *LocalizedError) Stack() *stacktrace.Stacktrace
- func (e *LocalizedError) Unwrap() error
Constants ¶
This section is empty.
Variables ¶
var Supported = []string{"en-US", "nl-NL"}
Supported languages
Functions ¶
func ErrorMessage ¶
func IsInputError ¶
IsInputError checks if the given error contains a InputError anywhere in the unwrap stack
func IsInputErrorNonRecursive ¶
IsInputErrorNonRecursive checks if the given error is an InputError
func JoinedErrorMessage ¶
JoinedErrorMessage joins all error messages in the Unwrap stack that are localized
func Tr ¶
Tr is like T but it accepts string params that will be used as numbered params, eg. V0, V1, V2 etc
func Tt ¶
Tt aliases to T, but before returning the string it replaces `[[` and `]]` with `{{` and `}}`, allowing for the localized strings to use these template tags without triggering i18n
func UnpackError ¶
UnpackError recursively unpacks the given error and returns all localized errors
Types ¶
type ErrorInput ¶
type ErrorInput interface {
InputError() bool
}
ErrorInput represents a user input error
type ErrorLocalizer ¶
ErrorLocalizer represents a localized error
type LocalizedError ¶
type LocalizedError struct {
// contains filtered or unexported fields
}
LocalizedError is an error that has the concept of user facing (localized) errors as well as whether an error is due to user input or not
func NewError ¶
func NewError(id string, args ...string) *LocalizedError
NewError creates a new error, it does a locale.Tl lookup of the given id, if the lookup fails it will use the locale string instead
func NewExternalError ¶
func NewExternalError(id string, args ...string) *LocalizedError
func NewInputError ¶
func NewInputError(id string, args ...string) *LocalizedError
NewInputError is like NewError but marks it as an input error
func WrapError ¶
func WrapError(err error, id string, args ...string) *LocalizedError
WrapError creates a new error that wraps the given error, it does a locale.Tt lookup of the given id, if the lookup fails it will use the locale string instead
func WrapExternalError ¶
func WrapExternalError(wrapTarget error, id string, args ...string) *LocalizedError
func WrapInputError ¶
func WrapInputError(err error, id string, args ...string) *LocalizedError
WrapInputError is like WrapError but marks it as an input error
func (*LocalizedError) AddTips ¶
func (e *LocalizedError) AddTips(tips ...string)
func (*LocalizedError) ErrorTips ¶
func (e *LocalizedError) ErrorTips() []string
func (*LocalizedError) ExternalError ¶
func (e *LocalizedError) ExternalError() bool
func (*LocalizedError) InputError ¶
func (e *LocalizedError) InputError() bool
InputError returns whether this is an error due to user input
func (*LocalizedError) LocaleError ¶
func (e *LocalizedError) LocaleError() string
LocaleError is the user facing error message, it's the same as Error() but identifies it as being user facing
func (*LocalizedError) Stack ¶
func (e *LocalizedError) Stack() *stacktrace.Stacktrace
Stack is the stacktrace leading up to where this error was triggered
func (*LocalizedError) Unwrap ¶
func (e *LocalizedError) Unwrap() error
Unwrap returns the parent error, if applicable