Documentation ¶
Overview ¶
Package errors helps you to write and design your own pre-defined errors, useful when you have a known list of errors
Index ¶
- Constants
- Variables
- type Error
- func (e Error) Append(format string, a ...interface{}) Error
- func (e Error) AppendErr(err error) Error
- func (e Error) Error() string
- func (e Error) Format(a ...interface{}) Error
- func (e Error) IsAppended() bool
- func (e Error) Panic()
- func (e Error) Panicf(args ...interface{})
- func (e Error) String() string
- func (e Error) With(err error) error
Examples ¶
Constants ¶
const (
// Version current version number
Version = "0.0.3"
)
Variables ¶
var ( // Prefix the error prefix, applies to each error's message // defaults to Error:_ Prefix = "Error: " // NewLine adds a new line to the end of each error's message // defaults to true NewLine = true )
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error holds the error message, this message never really changes
Example ¶
fmt.Print(errUserAlreadyExists.Format(userMail)) // first output first Output line fmt.Print(errUserAlreadyExists.Format(userMail).Append("Please change your mail addr")) // second output second and third Output lines
Output: Error: User with mail: user1@mail.go already exists Error: User with mail: user1@mail.go already exists Please change your mail addr
func New ¶
New creates and returns an Error with a pre-defined user output message all methods below that doesn't accept a pointer receiver because actualy they are not changing the original message
func (Error) Append ¶
Append adds a message to the predefined error message and returns a new error it does NOT change the original error's message
func (Error) AppendErr ¶
AppendErr adds an error's message to the predefined error message and returns a new error it does NOT change the original error's message
func (Error) Format ¶
Format returns a formatted new error based on the arguments it does NOT change the original error's message
func (Error) IsAppended ¶
IsAppended returns true if the Error instance is created using original's Error.Append/AppendErr func