commandpb

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_goes_command_error_proto protoreflect.FileDescriptor

File_goes_command_error_proto defines the Error and ErrorDetail message types used for representing errors in command execution. The Error message type contains an integer code, a string message, and a repeated field of ErrorDetail messages. The ErrorDetail message type contains a google.protobuf.Any field named "detail".

Functions

func AsError

func AsError[Code constraints.Integer](err *Error) *command.Err[Code]

AsError returns a command.Err value that wraps an Error.

Types

type Error

type Error struct {
	Code    int64          `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
	Message string         `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	Details []*ErrorDetail `protobuf:"bytes,3,rep,name=details,proto3" json:"details,omitempty"`
	// contains filtered or unexported fields
}

Error represents an error response from a command execution. It contains an error code, a message describing the error, and a list of ErrorDetails ErrorDetail.

func NewError

func NewError[Code constraints.Integer](err *command.Err[Code]) *Error

NewError returns a new instance of Error, an error type that wraps a command.Err and adds support for error details. The function takes a pointer to a command.Err as input and returns a pointer to an Error. If the input is nil, NewError returns an empty Error. The returned Error has its Code, Message, and Details fields set to the corresponding values of the input command.Err. NewError is generic over the integer type of the Code field of the input command.Err.

func (*Error) AsError

func (err *Error) AsError() *command.Err[int]

AsError returns the *command.Err[int] representation of an *Error.

func (*Error) Descriptor deprecated

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

Deprecated: Use Error.ProtoReflect.Descriptor instead.

func (*Error) GetCode

func (x *Error) GetCode() int64

GetCode returns the error code of an Error message.

func (*Error) GetDetails

func (x *Error) GetDetails() []*ErrorDetail

GetDetails returns a slice of *ErrorDetail containing details about the error. If there are no details, it returns nil.

func (*Error) GetMessage

func (x *Error) GetMessage() string

GetMessage returns the error message string of an Error type Error. If the Error is nil, an empty string is returned.

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

ProtoMessage *Error.ProtoMessage* is a method of the Error struct in the goes/commandpb package. It is implemented as an empty method and is part of the protoreflect.Message interface.

func (*Error) ProtoReflect

func (x *Error) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message representing the receiver. This method is used internally by the proto package and should not be called directly.

func (*Error) Reset

func (x *Error) Reset()

Reset resets the Error to its zero value. It also resets the message state if unsafe operations are enabled.

func (*Error) String

func (x *Error) String() string

String returns a string representation of the Error message. It is generated by the protoimpl library and uses Go's standard fmt package to format the message fields.

type ErrorDetail

type ErrorDetail struct {
	Detail *anypb.Any `protobuf:"bytes,1,opt,name=detail,proto3" json:"detail,omitempty"`
	// contains filtered or unexported fields
}

ErrorDetail represents a single detail of an error. It contains a field named Detail that is of type anypb.Any(https://pkg.go.dev/google.golang.org/protobuf/types/known/anypb#Any).

func NewErrorDetail

func NewErrorDetail(detail *command.ErrDetail) *ErrorDetail

NewErrorDetail creates a new ErrorDetail from a command.ErrDetail. The created ErrorDetail is used to add additional details to an Error.

func (*ErrorDetail) AsErrorDetail

func (detail *ErrorDetail) AsErrorDetail() *command.ErrDetail

AsErrorDetail converts an *ErrorDetail to a *command.ErrDetail.

func (*ErrorDetail) Descriptor deprecated

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

Deprecated: Use ErrorDetail.ProtoReflect.Descriptor instead.

func (*ErrorDetail) GetDetail

func (x *ErrorDetail) GetDetail() *anypb.Any

GetDetail returns the Any message contained in the ErrorDetail. It returns nil if the ErrorDetail is nil.

func (*ErrorDetail) ProtoMessage

func (*ErrorDetail) ProtoMessage()

ProtoMessage is a method implemented by ErrorDetail that marks the struct as implementing the protoreflect.ProtoMessage interface. This is required for any struct that needs to be serialized or deserialized using Protocol Buffers.

func (*ErrorDetail) ProtoReflect

func (x *ErrorDetail) ProtoReflect() protoreflect.Message

ProtoReflect returns the message's reflection interface, which is used to manipulate protobuf messages dynamically. It returns a protoreflect.Message that implements the Message interface in package google.golang.org/protobuf/reflect/protoreflect(https://godoc.org/google.golang.org/protobuf/reflect/protoreflect).

func (*ErrorDetail) Reset

func (x *ErrorDetail) Reset()

Reset resets the ErrorDetail to its zero value.

func (*ErrorDetail) String

func (x *ErrorDetail) String() string

String returns a string representation of the ErrorDetail message. It uses protoimpl.X.MessageStringOf to generate its output.

Jump to

Keyboard shortcuts

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