status

package
v0.0.0-...-db9179b Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: BSD-3-Clause Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Err

func Err(c uint32, msg string) error

Err returns an error representing c and msg. If c is OK, returns nil.

func Errf

func Errf(c uint32, format string, a ...interface{}) error

Errf returns Err(c, fmt.Sprintf(format, a...)).

Types

type Status

type Status struct {

	// The status code, which should be an enum value of [codes.Code][codes.Code].
	Code codes.Code `json:"code"`
	// A developer-facing error message, which should be in English. Any
	// user-facing error message should be localized and sent in the
	// [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
	Message string `json:"message"`
	// A list of messages that carry the error details.  There is a common set of
	// message types for APIs to use.
	Details []any `json:"details"`
}

Status https://cloud.google.com/apis/design/errors It is immutable and should be created with New, Newf, or FromProto.

func New

func New(c uint32, msg string) *Status

New returns a Status representing c and msg.

func Newf

func Newf(c uint32, format string, a ...any) *Status

Newf returns New(c, fmt.Sprintf(format, a...)).

func (*Status) Err

func (s *Status) Err() error

Err returns an immutable error representing s; returns nil if s.Code() is OK.

func (*Status) Error

func (s *Status) Error() string

func (*Status) GetCode

func (s *Status) GetCode() codes.Code

GetCode returns the status code contained in s.

func (*Status) GetMessage

func (s *Status) GetMessage() string

GetMessage returns the message contained in s.

func (*Status) String

func (s *Status) String() string

func (*Status) WithDetails

func (s *Status) WithDetails(details ...any) *Status

Jump to

Keyboard shortcuts

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