errors

package
v0.0.0-...-8c0e806 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: LGPL-3.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const (
	OptionType = iota
	OptionStatusCode
	OptionPriority
	OptionSeverity
	OptionNotifyTo
	OptionOutput
	OptionHTTPResponse

	TypeOK                 = "OK"
	TypeInternalError      = "InternalError"
	TypeConfigurationError = "ConfigurationError"
	TypeSecurity           = "Security"
	TypeInvalidData        = "InvalidData"
	TypeNetworkUnreachable = "NetworkUnreachable"

	PriorityLow    Priority = "LOW"
	PriorityMedium Priority = "MEDIUM"
	PriorityHigh   Priority = "HIGH"
	PriorityUrgent Priority = "URGENT"

	SeverityTrace    Severity = "TRACE"
	SeverityDebug    Severity = "DEBUG"
	SeverityInfo     Severity = "INFO"
	SeverityWarning  Severity = "WARNING"
	SeverityError    Severity = "ERROR"
	SeverityCritical Severity = "CRITICAL"
	SeverityFatal    Severity = "FATAL"
	SeverityPanic    Severity = "PANIC"
)

Variables

This section is empty.

Functions

func Cause

func Cause(err error) error

func Errorf

func Errorf(format string, args ...interface{}) error

func Errs

func Errs(errs []error) error

func New

func New(msg string) error

func Trace

func Trace() string

func Trace2

func Trace2() string

func Wrapf

func Wrapf(err error, format string, args ...interface{}) error

Types

type ErrOption

type ErrOption struct {
	Key   int
	Value interface{}
}

func SetHTTPResponse

func SetHTTPResponse(w http.ResponseWriter) ErrOption

func SetNotifyTo

func SetNotifyTo(u []string) ErrOption

func SetOutput

func SetOutput(out io.Writer) ErrOption

func SetPriority

func SetPriority(p Priority) ErrOption

func SetSeverity

func SetSeverity(s Severity) ErrOption

func SetStatusCode

func SetStatusCode(code int) ErrOption

func SetType

func SetType(t string) ErrOption

type Error

type Error struct {
	Error        ErrorSpec           `json:"error"`
	NotifyTo     []string            `json:"notifyTo,omitempty"`
	OutputWriter io.Writer           `json:"-"`
	HTTPWriter   http.ResponseWriter `json:"-"`
}

func Log

func Log(err error, errOpts ...ErrOption) *Error

func (*Error) Err

func (e *Error) Err() error

type ErrorSpec

type ErrorSpec struct {
	Message    string   `json:"message,omitempty"`
	Trace      string   `json:"trace,omitempty"`
	Type       string   `json:"type,omitempty"` // security | invalidData | networkUnreachable
	StatusCode int      `json:"statusCode,omitempty"`
	Priority   Priority `json:"priority,omitempty"`
	Severity   Severity `json:"severity,omitempty"`
}

type Priority

type Priority string

type Severity

type Severity string

Jump to

Keyboard shortcuts

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