Documentation
¶
Index ¶
- func Errore(err error, c codes.Code, msg string) error
- func Errorfe(err error, c codes.Code, format string, a ...any) 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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Errore ¶
Errore returns an error representing c and msg if err is not status.Status. If c is OK, returns nil. If err is status.Status already, return err. else, return an error representing c and msg marked with err.
func GetErrorWithLocalizedMessage ¶
GetErrorWithLocalizedMessage is a convenience function which removes the need to handle the error which may be not Status from GetLocalizedMessageError.
func GetLocalizedMessage ¶
GetLocalizedMessage returns an error that formats as the given Status with locale message or message. 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 ¶
GetLocalizedMessageError is a convenience function which returns an error that formats as the given Status with locale message or message.
func GetLocalizedMessageFromError ¶
GetLocalizedMessageFromError is a convenience function which removes the need to handle the error which may be not Status from GetLocalizedMessage.
Types ¶
type Status ¶
func Convert ¶
Convert is a convenience function which removes the need to handle the boolean return value from FromError. Deprecated: As of grpc 1.58.0, Use status.Convert instead.
func FromError
deprecated
FromError returns a Status representation of err.
If err was produced by this package or implements the method `GRPCStatus() *Status` and `GRPCStatus()` does not return nil, or if err wraps a type satisfying this, the Status from `GRPCStatus()` is returned. For wrapped errors, the message returned contains the entire err.Error() text and not just the wrapped status. In that case, ok is true.
If err is nil, a Status is returned with codes.OK and no message, and ok is true.
If err implements the method `GRPCStatus() *Status` and `GRPCStatus()` returns nil (which maps to Codes.OK), or if err wraps a type satisfying this, a Status is returned with codes.Unknown and err's Error() message, and ok is false.
Otherwise, err is an error not compatible with this package. In this case, a Status is returned with codes.Unknown and err's Error() message, and ok is false.
Deprecated: As of grpc 1.58.0, Use status.FromError instead.