Skip to content
Myr

Using uint64 for ErrorType

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Manu Mtz-Almeida · committed by Manu Mtz-Almeida · parent a373dc0 · Browse files · 2 files+12 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+12 added−10 removed

  • other:+12 added−10 removed

2 files+12 added−10 removed

modified:errors.go+11 added-9 removed
9 unmodified lines
10 "fmt"11 "reflect"12)1314type ErrorType uint641516const (15 ErrorTypeBind = 1 << 3016 ErrorTypeRender = 1 << 2917 ErrorTypePrivate = 1 << 018 ErrorTypePublic = 1 << 117 ErrorTypeBind ErrorType = 1 << 63 // used when c.Bind() fails18 ErrorTypeRender ErrorType = 1 << 62 // used when c.Render() fails19 ErrorTypePrivate ErrorType = 1 << 020 ErrorTypePublic ErrorType = 1 << 12120 ErrorTypeAny = 0xfffffff21 ErrorTypeNu = 222 ErrorTypeAny ErrorType = 1<<64 - 123 ErrorTypeNu = 224)2526type (27 Error struct {28 Err error `json:"error"`27 Type int `json:"-"`29 Type ErrorType `json:"-"`30 Meta interface{} `json:"meta"`31 }3233 errorMsgs []*Error34)3536var _ error = &Error{}3736func (msg *Error) SetType(flags int) *Error {38func (msg *Error) SetType(flags ErrorType) *Error {39 msg.Type = flags40 return msg41}42
30 unmodified lines
73func (msg *Error) Error() string {74 return msg.Err.Error()75}7675func (a errorMsgs) ByType(typ int) errorMsgs {77func (a errorMsgs) ByType(typ ErrorType) errorMsgs {78 if len(a) == 0 {79 return a80 }81 result := make(errorMsgs, 0, len(a))
59 unmodified lines
modified:logger.go+1 added-1 removed
23 unmodified lines
24func ErrorLogger() HandlerFunc {25 return ErrorLoggerT(ErrorTypeAny)26}2728func ErrorLoggerT(typ int) HandlerFunc {28func ErrorLoggerT(typ ErrorType) HandlerFunc {29 return func(c *Context) {30 c.Next()3132 if !c.Writer.Written() {
77 unmodified lines