github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/depends/kit/statusxgen/__examples__/status_error__generated.go (about) 1 // This is a generated source file. DO NOT EDIT 2 // Source: examples/status_error__generated.go 3 4 package examples 5 6 import "github.com/machinefi/w3bstream/pkg/depends/kit/statusx" 7 8 var _ statusx.Error = (*StatusError)(nil) 9 10 func (v StatusError) StatusErr() *statusx.StatusErr { 11 return &statusx.StatusErr{ 12 Key: v.Key(), 13 Code: v.Code(), 14 Msg: v.Msg(), 15 CanBeTalk: v.CanBeTalk(), 16 } 17 } 18 19 func (v StatusError) Unwrap() error { 20 return v.StatusErr() 21 } 22 23 func (v StatusError) Error() string { 24 return v.StatusErr().Error() 25 } 26 27 func (v StatusError) StatusCode() int { 28 return statusx.StatusCodeFromCode(int(v)) 29 } 30 31 func (v StatusError) Code() int { 32 if with, ok := (interface{})(v).(statusx.ServiceCode); ok { 33 return with.ServiceCode() + int(v) 34 } 35 return int(v) 36 } 37 38 func (v StatusError) Key() string { 39 switch v { 40 case Unauthorized: 41 return "Unauthorized" 42 case InternalServerError: 43 return "InternalServerError" 44 } 45 return "UNKNOWN" 46 } 47 48 func (v StatusError) Msg() string { 49 switch v { 50 case Unauthorized: 51 return "Unauthorized" 52 case InternalServerError: 53 return "InternalServerError 内部错误" 54 } 55 return "-" 56 } 57 58 func (v StatusError) CanBeTalk() bool { 59 switch v { 60 case Unauthorized: 61 return true 62 case InternalServerError: 63 return false 64 } 65 return false 66 }