Documentation ¶
Index ¶
- Constants
- Variables
- type GfSpError
- func (*GfSpError) Descriptor() ([]byte, []int)
- func (m *GfSpError) Error() string
- func (m *GfSpError) GetCodeSpace() string
- func (m *GfSpError) GetDescription() string
- func (m *GfSpError) GetHttpStatusCode() int32
- func (m *GfSpError) GetInnerCode() int32
- func (m *GfSpError) Marshal() (dAtA []byte, err error)
- func (m *GfSpError) MarshalTo(dAtA []byte) (int, error)
- func (m *GfSpError) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*GfSpError) ProtoMessage()
- func (m *GfSpError) Reset()
- func (m *GfSpError) SetError(err error)
- func (m *GfSpError) Size() (n int)
- func (m *GfSpError) String() string
- func (m *GfSpError) Unmarshal(dAtA []byte) error
- func (m *GfSpError) XXX_DiscardUnknown()
- func (m *GfSpError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *GfSpError) XXX_Merge(src proto.Message)
- func (m *GfSpError) XXX_Size() int
- func (m *GfSpError) XXX_Unmarshal(b []byte) error
- type GfSpErrorManager
Constants ¶
const ( // DefaultCodeSpace defines the default code space for not predefined error. DefaultCodeSpace = "GfSp" // DefaultInnerCode defines the default inner code for not predefined error. DefaultInnerCode = 999999 )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type GfSpError ¶ added in v0.2.4
type GfSpError struct { CodeSpace string `protobuf:"bytes,1,opt,name=code_space,json=codeSpace,proto3" json:"code_space,omitempty"` HttpStatusCode int32 `protobuf:"varint,2,opt,name=http_status_code,json=httpStatusCode,proto3" json:"http_status_code,omitempty"` InnerCode int32 `protobuf:"varint,3,opt,name=inner_code,json=innerCode,proto3" json:"inner_code,omitempty"` Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` }
func GfSpErrorList ¶ added in v0.2.4
func GfSpErrorList() []*GfSpError
GfSpErrorList returns the list of predefined errors, it is useful for query all predefined errors detailed info. Example:
list the errors by cli... etc. tools under troubleshooting.
func MakeGfSpError ¶ added in v0.2.4
MakeGfSpError returns an GfSpError from the build-in error interface. It is difficult to predefine all errors. For undefined errors, there needs to be a way to capture them and return them to the client according to the GfSpError format specified by the system. Of course, this is a guaranteed solution, the error should be well-defined is the most ideal.
If the input is not the GfSpError type, will use the DefaultCodeSpace and DefaultInnerCode, they are predefined by the reversed value, do not conflict with other predefined errors.
func Register ¶ added in v0.2.4
Register the predefined an error to the global error manager. Every error that needs to be displayed to the client needs to meet the format of GfSpError and be pre-defined in advance.
func (*GfSpError) Descriptor ¶ added in v0.2.4
func (*GfSpError) Error ¶ added in v0.2.4
Error implements the error interface for compatibility with built-in error.
func (*GfSpError) GetCodeSpace ¶ added in v0.2.4
func (*GfSpError) GetDescription ¶ added in v0.2.4
func (*GfSpError) GetHttpStatusCode ¶ added in v0.2.4
func (*GfSpError) GetInnerCode ¶ added in v0.2.4
func (*GfSpError) MarshalToSizedBuffer ¶ added in v0.2.4
func (*GfSpError) ProtoMessage ¶ added in v0.2.4
func (*GfSpError) ProtoMessage()
func (*GfSpError) SetError ¶ added in v0.2.4
SetError sets the Description field by Error(), it is use for change the predefined Description. Example: fill the predefined error's Description according to client info.
func (*GfSpError) XXX_DiscardUnknown ¶ added in v0.2.4
func (m *GfSpError) XXX_DiscardUnknown()
func (*GfSpError) XXX_Marshal ¶ added in v0.2.4
func (*GfSpError) XXX_Unmarshal ¶ added in v0.2.4
type GfSpErrorManager ¶
type GfSpErrorManager struct {
// contains filtered or unexported fields
}
GfSpErrorManager manages the predefined GfSpError, the GfSpError uses as the standard error format inside the SP system, it includes the CodeSpace, HttpStatusCode, InnerCode and Description fields. The HttpStatusCode uses to fill the http response header, the InnerCode and Description uses to fill the http response body if the request is failed, the CodeSpace and InnerCode uses to help developer tp quickly pinpoint the cause and location of errors.
The InnerCode detailed specifications can be found at:
"github.com/bnb-chain/greenfield-storage-provider/base/errors.md"
func (*GfSpErrorManager) AddErr ¶
func (g *GfSpErrorManager) AddErr(err *GfSpError)
AddErr add an error to the manager, predefined errors need to ensure the uniqueness of inner error codes.