Documentation
¶
Index ¶
- func Errore(c codes.Code, err error, details ...proto.Message) error
- func GetErrorWithLocalizedMessage(err error, locale string) error
- func GetLocalizedMessage(s *Status, locale string) string
- func GetLocalizedMessageError(s *Status, locale string) error
- func GetLocalizedMessageFromError(err error, locale string) string
- type Status
- func Convert(c codes.Code, err error, details ...proto.Message) *Status
- func FromError(c codes.Code, err error, details ...proto.Message) (s *Status, ok bool)
- func Newe(c codes.Code, err error, details ...proto.Message) *Status
- func WithBadRequestDetails(s *Status, descByField map[string]string) *Status
- func WithDetails(s *Status, details ...proto.Message) *Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetErrorWithLocalizedMessage ¶ added in v0.0.83
GetErrorWithLocalizedMessage is a convenience function which removes the need to handle the error which may be not Status from GetLocalizedMessageError.
func GetLocalizedMessage ¶ added in v0.0.83
The locale used following the specification defined at http://www.rfc-editor.org/rfc/bcp/bcp47.txt. Examples are: "en-US", "fr-CH", "es-MX", "zh-CN" advice: use locale generated by golang.org/x/text/language.Tag "en-US" : language.AmericanEnglish.String() "zh-CN" : language.SimplifiedChinese.String()
func GetLocalizedMessageError ¶ added in v0.0.83
GetLocalizedMessageError is a convenience function which returns an error that formats as the given Status with locale message or message.
func GetLocalizedMessageFromError ¶ added in v0.0.83
GetLocalizedMessageFromError is a convenience function which removes the need to handle the error which may be not Status from GetLocalizedMessage.
Types ¶
type Status ¶ added in v0.0.83
func Convert ¶
Convert is a convenience function which removes the need to handle the boolean return value from FromError.
func FromError ¶
FromError returns a Status representing err if it was produced from this package or has a method `GRPCStatus() *Status`. Otherwise, ok is false and a Status is returned with code.Code and the original error message.
code is set only if err has not implemented interface { GRPCStatus() *Status }
func Newe ¶
Newe returns a Status representing c and error, that is . if err == nil, return codes.OK if err != nil but c == codes.OK, return codes.Internal otherwise, return c
func WithBadRequestDetails ¶
WithBadRequestDetails returns a new status with the provided bad requests messages appended to the status.