errors

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

View Source
const (
	CONFLICT = "conflict"  // Action cannot be performed
	INTERNAL = "config"    // Internal error
	INVALID  = "invalid"   // Validation failed
	NOTFOUND = "not_found" // Entity does not exist
	TEMPLATE = "template"  // Templating error
)

Application error codes.

View Source
const GlobalError = "An error has occurred."

Global Error message when no message has been found.

Variables

This section is empty.

Functions

func Code

func Code(err error) string

Code

Returns the code of the root error, if available. Otherwise returns INTERNAL.

func Message

func Message(err error) string

Message

Returns the human-readable message of the error, if available. Otherwise returns a generic error message.

func New

func New(text string) error

New

Is a wrapper for the stdlib new function.

Types

type Error

type Error struct {
	Code      string `json:"code"`
	Message   string `json:"message"`
	Operation string `json:"operation"`
	Err       error  `json:"error"`
}

Error defines a standard application error.

func ToError

func ToError(err interface{}) *Error

ToError

Returns a Verbis error from input. If The type is not of type Error, nil will be returned.

func (*Error) Error

func (e *Error) Error() string

Error

Returns the string representation of the error message.

Jump to

Keyboard shortcuts

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