Documentation ¶
Index ¶
- Constants
- Variables
- func FmtError(e error) string
- func GetErrorMsg(e error) string
- func GetNestedError(e error) error
- func IsTemporaryErr(e error) bool
- func IsTimeoutErr(e error) bool
- func NewBasicError(msg string, e error, logCtx ...interface{}) error
- func TypeOf(v interface{}) string
- type BasicError
- type ByteOrderN
- type ErrorMsger
- type ErrorNester
- type Extension
- type ExtnBase
- type ExtnType
- type IFIDType
- type L4ProtocolType
- type Payload
- type RawBytes
- type Temporary
- type Timeout
Constants ¶
const ( // LineLen is the number of bytes that all SCION headers are padded to a multiple of. LineLen = 8 MinMTU = 1280 MaxMTU = (1 << 16) - 1 TimeFmt = "2006-01-02 15:04:05.000000-0700" )
const ( BR = "BR" BS = "BS" PS = "PS" CS = "CS" SB = "SB" RS = "RS" DS = "DS" )
const ( // Maximum allowed hop-by-hop extensions, excluding a potential leading SCMP extension. ExtnMaxHBH = 3 ExtnSubHdrLen = 3 ExtnFirstLineLen = LineLen - ExtnSubHdrLen )
const IFIDBytes = 8
Variables ¶
var ( Order ByteOrderN = newBigEndianN() NativeOrder ByteOrderN IsBigEndian bool )
var ( ExtnSCMPType = ExtnType{HopByHopClass, 0} ExtnOneHopPathType = ExtnType{HopByHopClass, 1} ExtnSIBRAType = ExtnType{HopByHopClass, 2} ExtnPathTransType = ExtnType{End2EndClass, 0} ExtnPathProbeType = ExtnType{End2EndClass, 1} ExtnSCIONPacketSecurityType = ExtnType{End2EndClass, 2} )
var L4Protocols = map[L4ProtocolType]bool{ L4SCMP: true, L4TCP: true, L4UDP: true, }
Functions ¶
func FmtError ¶
FmtError formats e for logging. It walks through all nested errors, putting each on a new line, and indenting multi-line errors.
func GetErrorMsg ¶
GetErrorMsg extracts the message from e, if e implements the ErrorMsger interface. As a fall-back, if e implements ErrorNester, GetErrorMsg recurses on the nested error. Otherwise returns an empty string.
func GetNestedError ¶
GetNestedError returns the nested error, if any. Returns nil otherwise.
func IsTemporaryErr ¶
IsTemporaryErr determins if e is a temporary Error. As a fall-back, if e implements ErrorNester, IsTemporaryErr recurses on the nested error. Otherwise returns false.
func IsTimeoutErr ¶
IsTimeoutErr determins if e is a temporary Error. As a fall-back, if e implements ErrorNester, IsTimeoutErr recurses on the nested error. Otherwise returns false.
func NewBasicError ¶
NewBasicError creates a new BasicError, with e as the embedded error (can be nil), with logCtx being a list of string/val pairs.
Types ¶
type BasicError ¶
type BasicError struct { // Error message Msg string // Nested error, if any. Err error // contains filtered or unexported fields }
BasicError is a simple error type that implements ErrorMsger and ErrorNester, and can contain context (slice of [string, val, string, val...]) for logging purposes.
func (BasicError) Error ¶
func (be BasicError) Error() string
func (BasicError) GetErr ¶
func (be BasicError) GetErr() error
func (BasicError) GetMsg ¶
func (be BasicError) GetMsg() string
func (BasicError) TopError ¶
func (be BasicError) TopError() string
type ByteOrderN ¶
type ErrorMsger ¶
ErrorMsger allows extracting the message from an error. This means a caller can determine the type of error by comparing the returned message with a const error string. E.g.:
if GetErrorMsg(err) == addr.ErrorBadHostAddrType { // Handle bad host addr error }
type ErrorNester ¶
type ErrorNester interface { error TopError() string // should not include the nested error GetErr() error }
ErrorNester allows recursing into nested errors.
type ExtnBase ¶
type ExtnBase interface { // Length in bytes, excluding 3B subheader Len() int Class() L4ProtocolType Type() ExtnType fmt.Stringer }
type ExtnType ¶
type ExtnType struct { Class L4ProtocolType Type uint8 }
type L4ProtocolType ¶
type L4ProtocolType uint8
const ( L4None L4ProtocolType = 0 L4SCMP L4ProtocolType = 1 L4TCP L4ProtocolType = 6 L4UDP L4ProtocolType = 17 HopByHopClass L4ProtocolType = 0 End2EndClass L4ProtocolType = 222 )
func (L4ProtocolType) String ¶
func (p L4ProtocolType) String() string
type Temporary ¶
Temporary allows signalling of a temporary error. Based on https://golang.org/pkg/net/#Error
type Timeout ¶
Temporary allows signalling of a timeout error. Based on https://golang.org/pkg/net/#Error