vterrors

package
v2.0.0-alpha1+incompat... Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2015 License: BSD-3-Clause Imports: 3 Imported by: 5

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 (
	// TabletError is the base VtTablet error. All VtTablet errors should be 4 digits, starting with 1.
	TabletError = 1000
	// UnknownTabletError is the code for an unknown error that came from VtTablet.
	UnknownTabletError = 1999
	// VtgateError is the base VTGate error code. All VTGate errors should be 4 digits, starting with 2.
	VtgateError = 2000
	// UnknownVtgateError is the code for an unknown error that came from VTGate.
	UnknownVtgateError = 2999
)

Variables

This section is empty.

Functions

func FromError

func FromError(code int64, err error) error

FromError returns a VitessError with the supplied error code and wrapped error.

func FromRPCError

func FromRPCError(rpcErr *mproto.RPCError) error

FromRPCError recovers a VitessError from a *RPCError (which is how VitessErrors are transmitted across RPC boundaries).

func WithPrefix

func WithPrefix(prefix string, in error) error

WithPrefix allows a string to be prefixed to an error, without nesting a new VitessError.

Types

type VitessError

type VitessError struct {
	// Error code of the Vitess error
	Code int64
	// Additional context string, distinct from the error message. For example, if
	// you wanted an error like "foo error: original error", the Message string
	// should be "foo error: "
	Message string
	// contains filtered or unexported fields
}

VitessError is the error type that we use internally for passing structured errors

func FromVtRPCError

func FromVtRPCError(rpcErr *pb.RPCError) *VitessError

FromVtRPCError recovers a VitessError from a *vtrpc.RPCError (which is how VitessErrors are transmitted across proto3 RPC boundaries).

func (*VitessError) AsString

func (e *VitessError) AsString() string

AsString returns a VitessError as a string, with more detailed information than Error().

func (*VitessError) Error

func (e *VitessError) Error() string

Error implements the error interface. For now, it should exactly recreate the original error string. It intentionally (for now) does not expose all the information that VitessError has. This is so that it can be used in the mixed state where parts of the stack are trying to parse error strings.

Jump to

Keyboard shortcuts

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