errors

package
v0.0.0-...-d57715f Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Code for error
	// UnknownCode is unknown code for error info.
	UnknownCode = 500
	NoError     = 0
	ServerError = 499
	ParamError  = 400
	// UnknownReason is unknown reason for error info.
	UnknownReason = ""
)
View Source
const (
	ErrFileNotFound          = "file '%s' not found"
	ErrFileAlreadyExists     = "file '%s' already exists"
	ErrTemplateNotFound      = "template '%s' not found"
	ErrBaseDirectoryNotFound = "base directory '%s' not found"
	ErrDirectoryNotFound     = "directory '%s' not found"
	ErrScriptNotFound        = "script '%s' not found"
)

Variables

This section is empty.

Functions

func Code

func Code(err error) int

Code returns the http code for an error. It supports wrapped errors.

func Reason

func Reason(err error) string

Reason returns the reason for a particular error. It supports wrapped errors.

Types

type Error

type Error struct {
	Code    int32  `json:"code,omitempty"`
	Reason  string `json:"reason,omitempty"`
	Message string `json:"message,omitempty"`
}

func FromError

func FromError(err error) *Error

FromError try to convert an error to *Error. It supports wrapped errors.

func New

func New(code int, reason, message string) *Error

New returns an error object for the code, message.

func Newf

func Newf(code int, reason, format string, a ...interface{}) *Error

Newf New(code fmt.Sprintf(format, a...))

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(err error) bool

Is matches each error in the chain with the target value.

Jump to

Keyboard shortcuts

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