Documentation ¶
Overview ¶
Package vterrors provides helpers for propagating internal errors through the Vitess system (including across RPC boundaries) in a structured way.
Index ¶
Constants ¶
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 FromRPCError ¶
FromRPCError recovers a VitessError from a *RPCError (which is how VitessErrors are transmitted across RPC boundaries).
func WithPrefix ¶
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.