failure

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: MIT Imports: 2 Imported by: 27

README

Failure

The failure package builds upon the errors package, implementing a strategy called Opaque errors which I first learned about from an article [Don't just check errors handle the gracefully] (https://dave.cheney.net/2016/04/27/dont-just-check-errors-handle-them-gracefully) by Dave Cheney who I believe is also the author of the errors package.

Failure is geared towards describing errors that occur while using microservices that generally support rest api's and as such you will notice a slight bias towards that, although I try to separate concerns as much as possible. It is heavily influenced by sls a library used to develop AWS Serverless applications using Golang and Terraform.

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

View Source
const (
	SystemMsg     = "system failure"
	ServerMsg     = "server failure"
	NotFoundMsg   = "not found failure"
	ValidationMsg = "validation failure"
	DeferMsg      = "failure occurred inside defer"
	IgnoreMsg     = "ignore failure"
	ConfigMsg     = "config failure"
)

Variables

This section is empty.

Functions

func Config added in v0.3.0

func Config(format string, a ...interface{}) error

Config is used to signify that error occurred when processing the application configuration

func Defer added in v0.2.0

func Defer(format string, a ...interface{}) error

Defer is used to signify errors that originate inside a defer function

func Ignore

func Ignore(format string, a ...interface{}) error

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 Input

func Input(internalErr error, format string, a ...interface{}) error

func InputMsg

func InputMsg(e error) (string, bool)

func IsConfig added in v0.3.0

func IsConfig(err error) bool

func IsDefer added in v0.2.0

func IsDefer(err error) bool

func IsIgnore

func IsIgnore(err error) bool

func IsInput

func IsInput(e error) bool

func IsNotFound

func IsNotFound(err error) bool

func IsServer

func IsServer(err error) bool

IsServer will return true if the cause is a serverErr

func IsSystem

func IsSystem(err error) bool

func IsValidation

func IsValidation(err error) bool

func NotFound

func NotFound(format string, a ...interface{}) error

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 Server

func Server(format string, a ...interface{}) error

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

func System(format string, a ...interface{}) error

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 ToConfig added in v0.3.0

func ToConfig(e error, format string, a ...interface{}) error

func ToDefer added in v0.2.0

func ToDefer(e error, format string, a ...interface{}) error

func ToIgnore

func ToIgnore(e error, format string, a ...interface{}) error

ToIgnore converts `e` into the root cause of ignoreErr, it informs the system to ignore error. Used typically to log results and do not act on the error itself.

func ToNotFound

func ToNotFound(e error, format string, a ...interface{}) error

func ToServer

func ToServer(e error, format string, a ...interface{}) error

func ToSystem

func ToSystem(e error, format string, a ...interface{}) error

func ToValidation

func ToValidation(e error, format string, a ...interface{}) error

func Validation

func Validation(format string, a ...interface{}) error

Validation is used to signify that a validation rule as been violated

func Wrap

func Wrap(err error, msg string, a ...interface{}) error

Wrap expose errors.Wrapf as our default wrapping style

Types

This section is empty.

Jump to

Keyboard shortcuts

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