Documentation ¶
Overview ¶
Package vterrors provides helpers for propagating internal errors through the Vitess system (including across RPC boundaries) in a structured way.
Index ¶
- Constants
- func Aggregate(errors []error) error
- func Code(err error) vtrpcpb.Code
- func CodeToLegacyErrorCode(code vtrpcpb.Code) vtrpcpb.LegacyErrorCode
- func Equals(a, b error) bool
- func Errorf(code vtrpcpb.Code, format string, args ...interface{}) error
- func FromGRPC(err error) error
- func FromVTRPC(rpcErr *vtrpcpb.RPCError) error
- func LegacyErrorCodeToCode(code vtrpcpb.LegacyErrorCode) vtrpcpb.Code
- func New(code vtrpcpb.Code, in string) error
- func Print(err error) string
- func ToGRPC(err error) error
- func ToVTRPC(err error) *vtrpcpb.RPCError
- func Wrap(err error, message string) error
- func Wrapf(err error, format string, args ...interface{}) error
Constants ¶
const ( // Informational errors. PriorityOK = iota PriorityCanceled PriorityAlreadyExists PriorityOutOfRange // Potentially retryable errors. PriorityDeadlineExceeded PriorityAborted PriorityFailedPrecondition // Permanent errors. PriorityResourceExhausted PriorityUnknown PriorityUnauthenticated PriorityPermissionDenied PriorityInvalidArgument PriorityNotFound PriorityUnimplemented // Serious errors. PriorityInternal PriorityDataLoss )
A list of all vtrpcpb.Code, ordered by priority. These priorities are used when aggregating multiple errors in VtGate. Higher priority error codes are more urgent for users to see. They are prioritized based on the following question: assuming a scatter query produced multiple errors, which of the errors is the most likely to give the user useful information about why the query failed and how they should proceed?
Variables ¶
This section is empty.
Functions ¶
func Aggregate ¶
Aggregate aggregates several errors into a single one. The resulting error code will be the one with the highest priority as defined by the priority constants in this package.
func Code ¶
Code returns the error code if it's a vtError. If err is nil, it returns ok. Otherwise, it returns unknown.
func CodeToLegacyErrorCode ¶
func CodeToLegacyErrorCode(code vtrpcpb.Code) vtrpcpb.LegacyErrorCode
CodeToLegacyErrorCode maps a vtrpcpb.Code to a vtrpcpb.LegacyErrorCode.
func FromGRPC ¶
FromGRPC returns a gRPC error as a vtError, translating between error codes. However, there are a few errors which are not translated and passed as they are. For example, io.EOF since our code base checks for this error to find out that a stream has finished.
func FromVTRPC ¶
FromVTRPC recovers a vtError from a *vtrpcpb.RPCError (which is how vtError is transmitted across proto3 RPC boundaries).
func LegacyErrorCodeToCode ¶
func LegacyErrorCodeToCode(code vtrpcpb.LegacyErrorCode) vtrpcpb.Code
LegacyErrorCodeToCode maps a vtrpcpb.LegacyErrorCode to a gRPC vtrpcpb.Code.
func Print ¶
Print is meant to print the vtError object in test failures. For comparing two vterrors, use Equals() instead.
Types ¶
This section is empty.