errors

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CONFLICT - An action cannot be performed.
	CONFLICT = "conflict"
	// INTERNAL - Error within Go Mail
	INTERNAL = "internal" // Internal error
	// INVALID - Validation failed
	INVALID = "invalid" // Validation failed
	// API - Error in the http request.
	API = "api"
	// Prefix is the string prefixed to an error message.
	Prefix = "go-mail"
	// GlobalError is a general message when no error message
	// has been found.
	GlobalError = "An error has occurred."
)

Application error codes.

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 Go Mail 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