status

package
v1.1.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errore

func Errore(c codes.Code, err error, details ...proto.Message) error

Errore returns an error representing c and error. If err is nil, returns nil.

func GetErrorWithLocalizedMessage added in v0.0.83

func GetErrorWithLocalizedMessage(err error, locale string) error

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

func GetLocalizedMessage(s *Status, locale string) string

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

func GetLocalizedMessageError(s *Status, locale string) error

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

func GetLocalizedMessageFromError(err error, locale string) string

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

type Status = status.Status

func Convert

func Convert(c codes.Code, err error, details ...proto.Message) *Status

Convert is a convenience function which removes the need to handle the boolean return value from FromError.

func FromError

func FromError(c codes.Code, err error, details ...proto.Message) (s *Status, ok bool)

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

func Newe(c codes.Code, err error, details ...proto.Message) *Status

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

func WithBadRequestDetails(s *Status, descByField map[string]string) *Status

WithBadRequestDetails returns a new status with the provided bad requests messages appended to the status.

func WithDetails

func WithDetails(s *Status, details ...proto.Message) *Status

WithDetails returns a new status with the provided details messages appended to the status. If any errors are encountered, it returns original status. WithDetails does not change original code always.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL