errdetails

package
v0.16.8 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

Error details

Package contains proto representation for details section inside error response.

Proto file defines TargetInfo message which is a default representation of error details that conforms REST API Syntax Specification. It has it's own specific marshal/unmarshal logic.

This functionality should not be directly used in your code. Use WithDetails function from errors package instead.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TargetInfo

type TargetInfo struct {
	// The status code is an enumerated error code,
	// which should be an enum value of [google.rpc.Code][google.rpc.Code]
	Code int32 `protobuf:"varint,1,opt,name=code" json:"code,omitempty"`
	// The message is a human-readable non-localized message
	Message string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"`
	// The target is a resource name
	Target               string   `protobuf:"bytes,3,opt,name=target" json:"target,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

TargetInfo is a default representation of error details that conforms REST API Syntax Specification

func New

func New(c codes.Code, target string, msg string) *TargetInfo

New returns a TargetInfo representing c, target and msg. Converts provided Code to int32

func Newf

func Newf(c codes.Code, target string, format string, a ...interface{}) *TargetInfo

NewfTargetInfo returns NewTargetInfo(c, fmt.Sprintf(format, a...)).

func (*TargetInfo) Descriptor

func (*TargetInfo) Descriptor() ([]byte, []int)

func (*TargetInfo) GetCode

func (m *TargetInfo) GetCode() int32

func (*TargetInfo) GetMessage

func (m *TargetInfo) GetMessage() string

func (*TargetInfo) GetTarget

func (m *TargetInfo) GetTarget() string

func (*TargetInfo) MarshalJSON

func (ti *TargetInfo) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. TargetInfo.Code field is marshaled into string with corresponding value, see [google.rpc.Code][google.rpc.Code], if code is the codes.Unimplemented it is marshaled as "NOT_IMPLEMENTED" string.

func (*TargetInfo) ProtoMessage

func (*TargetInfo) ProtoMessage()

func (*TargetInfo) Reset

func (m *TargetInfo) Reset()

func (*TargetInfo) String

func (m *TargetInfo) String() string

func (*TargetInfo) UnmarshalJSON

func (ti *TargetInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. If "code" is not provided in JSON data or is null, the TargetInfo.Code will be set to 0 (OK)

func (*TargetInfo) XXX_DiscardUnknown added in v0.6.0

func (m *TargetInfo) XXX_DiscardUnknown()

func (*TargetInfo) XXX_Marshal added in v0.6.0

func (m *TargetInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TargetInfo) XXX_Merge added in v0.6.0

func (dst *TargetInfo) XXX_Merge(src proto.Message)

func (*TargetInfo) XXX_Size added in v0.6.0

func (m *TargetInfo) XXX_Size() int

func (*TargetInfo) XXX_Unmarshal added in v0.6.0

func (m *TargetInfo) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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