Documentation ¶
Index ¶
- Variables
- func AsError[Code constraints.Integer](err *Error) *command.Err[Code]
- type Error
- func (err *Error) AsError() *command.Err[int]
- func (*Error) Descriptor() ([]byte, []int)deprecated
- func (x *Error) GetCode() int64
- func (x *Error) GetDetails() []*ErrorDetail
- func (x *Error) GetMessage() string
- func (*Error) ProtoMessage()
- func (x *Error) ProtoReflect() protoreflect.Message
- func (x *Error) Reset()
- func (x *Error) String() string
- type ErrorDetail
- func (detail *ErrorDetail) AsErrorDetail() *command.ErrDetail
- func (*ErrorDetail) Descriptor() ([]byte, []int)deprecated
- func (x *ErrorDetail) GetDetail() *anypb.Any
- func (*ErrorDetail) ProtoMessage()
- func (x *ErrorDetail) ProtoReflect() protoreflect.Message
- func (x *ErrorDetail) Reset()
- func (x *ErrorDetail) String() string
Constants ¶
This section is empty.
Variables ¶
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 ¶
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) Descriptor
deprecated
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 ¶
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.
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.