Documentation
¶
Overview ¶
Package failure implements an opaque error pattern based several of the most common types of errors that occur when developing microservices.
Index ¶
- Constants
- func Ignore(format string, a ...interface{}) error
- func Input(internalErr error, format string, a ...interface{}) error
- func InputMsg(e error) (string, bool)
- func IsIgnore(err error) bool
- func IsInput(e error) bool
- func IsNotFound(err error) bool
- func IsPlatform(err error) bool
- func IsServer(err error) bool
- func IsSystem(err error) bool
- func IsValidation(err error) bool
- func NotFound(format string, a ...interface{}) error
- func Platform(format string, a ...interface{}) error
- func Server(format string, a ...interface{}) error
- func System(format string, a ...interface{}) error
- func ToIgnore(e error, format string, a ...interface{}) error
- func ToNotFound(e error, format string, a ...interface{}) error
- func ToPlatform(e error, format string, a ...interface{}) error
- func ToServer(e error, format string, a ...interface{}) error
- func ToSystem(e error, format string, a ...interface{}) error
- func ToValidation(e error, format string, a ...interface{}) error
- func Validation(format string, a ...interface{}) error
- func Wrap(err error, msg string, a ...interface{}) error
Constants ¶
const ( SystemMsg = "system failure" PlatformMsg = "platform failure" ServerMsg = "server failure" NotFoundMsg = "not found failure" ValidationMsg = "validation failure" IgnoreMsg = "ignore failure" )
Variables ¶
This section is empty.
Functions ¶
func Ignore ¶
Ignore is used to signify that error should not be acted on, it's up to the handler to decide to log these errors or not.
func IsNotFound ¶
func IsPlatform ¶
IsPlatform will return true if the cause is a platErr
func IsValidation ¶
func NotFound ¶
NotFound is used to signify that whatever resource you were looking for does not exist and that fact it does not exist is an error.
func Platform ¶
Platform failure is intended to represent low level errors that originate at the most concrete part of your architecture. I typically name this layer as platform hence the error type. It has the same meaning as Server or System. The idea is you choose the name that reads the best for your code and stay with that one. It is not recommended mixing these.
func Server ¶
Server has the same meaning as Platform or System, it can be used instead if you don't like how Platform or System reads in your code.
func System ¶
System is has the same meaning as Platform or Server, it can be used instead if you don't like how Platform reads in your code
func ToIgnore ¶
ToIgnore converts `e` into the root cause of ignoreErr, it informs the system to ignore this outside error.
func ToNotFound ¶
ToNotFound converts `e` into the root cause of errNotFound
func ToPlatform ¶
ToPlatform will convert err to the root cause as a Platform type. This is used when the `Platform Layer` of your code any library other than your own, and you want that error to be the root cause as type Platform. This will preserve the original message, just moving it into the new type.
func ToServer ¶
ToServer behaves in the same manner as any ToXX function. Making err the root cause of type systemErr in our wrap.
func ToSystem ¶
ToSystem behaves in the same manner as any ToXX function. Making err the root cause of type systemErr in our wrap.
func ToValidation ¶
ToValidation converts `e` into the root cause of errNotFound
func Validation ¶
Validation is used to signify that a validation rule as been violated
Types ¶
This section is empty.