Documentation ¶
Index ¶
- func StatusCodeFromCode(code int) int
- type ErrorField
- type ErrorFields
- type StatusErr
- func (statusErr StatusErr) AppendErrorField(in string, field string, msg string) *StatusErr
- func (statusErr StatusErr) AppendErrorFields(errorFields ...*ErrorField) *StatusErr
- func (statusErr StatusErr) AppendSource(sourceName string) *StatusErr
- func (statusErr StatusErr) DisableErrTalk() *StatusErr
- func (statusErr StatusErr) EnableErrTalk() *StatusErr
- func (statusErr *StatusErr) Error() string
- func (statusErr *StatusErr) Format(s fmt.State, verb rune)
- func (statusErr *StatusErr) Is(err error) bool
- func (statusErr *StatusErr) StatusCode() int
- func (statusErr *StatusErr) Summary() string
- func (statusErr *StatusErr) Unwrap() error
- func (statusErr StatusErr) WithDesc(desc string) *StatusErr
- func (statusErr StatusErr) WithID(id string) *StatusErr
- func (statusErr StatusErr) WithMsg(msg string) *StatusErr
- type StatusError
- type StatusErrorWithServiceCode
- type WithStackTrace
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StatusCodeFromCode ¶
Types ¶
type ErrorField ¶
type ErrorField struct { // field path // prop.slice[2].a Field string `json:"field" xml:"field"` // msg Msg string `json:"msg" xml:"msg"` // location // eq. body, query, header, path, formData In string `json:"in" xml:"in"` }
func NewErrorField ¶
func NewErrorField(in string, field string, msg string) *ErrorField
func (ErrorField) String ¶
func (s ErrorField) String() string
type ErrorFields ¶
type ErrorFields []*ErrorField
func (ErrorFields) Len ¶
func (fields ErrorFields) Len() int
func (ErrorFields) Less ¶
func (fields ErrorFields) Less(i, j int) bool
func (ErrorFields) String ¶
func (fields ErrorFields) String() string
func (ErrorFields) Swap ¶
func (fields ErrorFields) Swap(i, j int)
type StatusErr ¶
type StatusErr struct { // key of err Key string `json:"key" xml:"key"` // http code Code int `json:"code" xml:"code"` // msg of err Msg string `json:"msg" xml:"msg"` // desc of err Desc string `json:"desc" xml:"desc"` // can be task error // for client to should error msg to end user CanBeTalkError bool `json:"canBeTalkError" xml:"canBeTalkError"` // request ID or other request context ID string `json:"id" xml:"id"` // error tracing Sources []string `json:"sources" xml:"sources"` // error in where fields ErrorFields ErrorFields `json:"errorFields" xml:"errorFields"` // contains filtered or unexported fields }
Example ¶
fmt.Println(examples.Unauthorized) fmt.Println(statuserror.FromErr(nil)) fmt.Println(statuserror.FromErr(fmt.Errorf("unknown")))
Output: []@StatusErr[Unauthorized][401999001][Unauthorized]! <nil> []@StatusErr[UnknownError][500000000][unknown error] unknown
func IsStatusErr ¶
func ParseStatusErrSummary ¶
func (StatusErr) AppendErrorField ¶
func (StatusErr) AppendErrorFields ¶
func (statusErr StatusErr) AppendErrorFields(errorFields ...*ErrorField) *StatusErr
func (StatusErr) AppendSource ¶
func (StatusErr) DisableErrTalk ¶
func (StatusErr) EnableErrTalk ¶
func (*StatusErr) StatusCode ¶
type StatusError ¶
type StatusErrorWithServiceCode ¶
type StatusErrorWithServiceCode interface {
ServiceCode() int
}
type WithStackTrace ¶
type WithStackTrace interface {
StackTrace() errors.StackTrace
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.