Documentation ¶
Index ¶
- Variables
- type Error
- func (e Error) Append(format string, a ...interface{}) Error
- func (e Error) AppendErr(err error) Error
- func (e Error) AppendInline(format string, a ...interface{}) Error
- func (e Error) Empty() bool
- func (e Error) Equal(to error) bool
- func (e Error) Error() string
- func (e Error) Format(a ...interface{}) Error
- func (e Error) HasStack() bool
- func (e Error) Ignore(err error) error
- func (e Error) NotEmpty() bool
- func (e Error) Panic()
- func (e Error) Panicf(args ...interface{})
- func (e Error) String() string
- func (e Error) With(err error) error
Constants ¶
This section is empty.
Variables ¶
var (
Prefix = ""
)
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct { // ID returns the unique id of the error, it's needed // when we want to check if a specific error returned // but the `Error() string` value is not the same because the error may be dynamic // by a `Format` call. ID string `json:"id"` // The message of the error. Message string `json:"message"` // Apennded is true whenever it's a child error. Appended bool `json:"appended"` // Stack returns the list of the errors that are shown at `Error() string`. Stack []Error `json:"stack"` // filled on AppendX. }
func NewErrors ¶
New creates and returns an Error with a pre-defined user output message all methods below that doesn't accept a pointer receiver because actually they are not changing the original message
func NewFromErr ¶
NewFromErr same as `New` but pointer for nil checks without the need of the `Return()` function.
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) AppendInline ¶
AppendInline appends an error to the stack. It doesn't try to append a new line if needed.
func (Error) Equal ¶
Equal returns true if "e" and "to" are matched, by their IDs if it's a core/errors type otherwise it tries to match their error messages. It will always returns true if the "to" is a children of "e" or the error messages are exactly the same, otherwise false.
func (Error) Format ¶
Format returns a formatted new error based on the arguments it does NOT change the original error's message
func (Error) HasStack ¶
HasStack returns true if the Error instance is created using Append/AppendInline/AppendErr funcs.
func (Error) NotEmpty ¶
NotEmpty returns true if the "e" Error has got a non-empty message on its stack.