Documentation
¶
Index ¶
Constants ¶
const ( // AttrGRPCMethod is the simplerr attribute key for retrieving the grpc method AttrGRPCMethod = attr(1) // AttrGRPCStatus is the simplerr attribute key for retrieving the grpc Status object AttrGRPCStatus = attr(2) )
Variables ¶
This section is empty.
Functions ¶
func DefaultInverseMapping ¶ added in v1.4.0
DefaultInverseMapping returns the default inverse mapping of gRPC error codes to SimpleError codes
func DefaultMapping ¶
DefaultMapping returns the default mapping of SimpleError codes to gRPC error codes
func ReturnSimpleErrors ¶ added in v1.4.0
func ReturnSimpleErrors(registry *Registry) grpc.UnaryClientInterceptor
ReturnSimpleErrors returns a unary client interceptor that converts errors returned by the client to simplerr compatible errors. The underlying grpc status and code can still be extracted using the same status.FromError() and status.Code() methods
func TranslateErrorCode ¶
func TranslateErrorCode(registry *Registry) grpc.UnaryServerInterceptor
TranslateErrorCode inspects the error to see if it is a SimpleError. If it is, it attempts to translate the SimpleError code to the corresponding grpc error code. If no translation exists it returns a grpc error with Unknown error code.
Types ¶
type Registry ¶ added in v1.4.0
type Registry struct {
// contains filtered or unexported fields
}
Registry is a registry which contains the mapping between simplerr codes and grpc error codes
func GetDefaultRegistry ¶ added in v1.4.0
func GetDefaultRegistry() *Registry
GetDefaultRegistry returns the currently registered default registry used by this package.
func NewRegistry ¶ added in v1.4.0
func NewRegistry() *Registry
NewRegistry creates a new registry which contains the mapping to and from simplerr codes and grpc error codes
func (*Registry) SetInverseMapping ¶ added in v1.4.0
SetInverseMapping sets the mapping from gRPC code to simplerr.Code