vterrors

package
v2.2.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: May 18, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package vterrors provides helpers for propagating internal errors through the Vitess system (including across RPC boundaries) in a structured way.

Index

Constants

View Source
const (
	// Informational errors.
	PriorityOK = iota
	PriorityCanceled
	PriorityAlreadyExists
	PriorityOutOfRange
	// Potentially retryable errors.
	PriorityUnavailable
	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

func Aggregate(errors []error) error

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

func Code(err error) vtrpcpb.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 Equals

func Equals(a, b error) bool

Equals returns true iff the error message and the code returned by Code() is equal.

func Errorf

func Errorf(code vtrpcpb.Code, format string, args ...interface{}) error

Errorf returns a new error built using Printf style arguments.

func FromGRPC

func FromGRPC(err error) error

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

func FromVTRPC(rpcErr *vtrpcpb.RPCError) error

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 New

func New(code vtrpcpb.Code, in string) error

New creates a new error using the code and input string.

func Print

func Print(err error) string

Print is meant to print the vtError object in test failures. For comparing two vterrors, use Equals() instead.

func ToGRPC

func ToGRPC(err error) error

ToGRPC returns an error as a gRPC error, with the appropriate error code.

func ToVTRPC

func ToVTRPC(err error) *vtrpcpb.RPCError

ToVTRPC converts from vtError to a vtrpcpb.RPCError.

func Wrap

func Wrap(err error, message string) error

Wrap wraps the given error, returning a new error with the given message as a prefix but with the same error code (if err was a vterror) and message of the passed error.

func Wrapf

func Wrapf(err error, format string, args ...interface{}) error

Wrapf wraps the given error, returning a new error with the given format string as a prefix but with the same error code (if err was a vterror) and message of the passed error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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