exc

package
v3.0.0-alpha.28 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 2 Imported by: 5

Documentation

Overview

Package exc provides an error type for capnp exceptions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsType

func IsType(err error, t Type) bool

IsType reports whether any error in err's is an Exception whose type matches 't'.

The chain consists of err itself followed by the sequence of errors obtained by repeatedly calling Unwrap.

func WrapError

func WrapError(prefix string, err error) error

Types

type Annotator

type Annotator string

func (Annotator) Annotate

func (f Annotator) Annotate(err error, msg string) *Exception

func (Annotator) Disconnected

func (f Annotator) Disconnected(err error) *Exception

func (Annotator) Failed

func (f Annotator) Failed(err error) *Exception

func (Annotator) New

func (f Annotator) New(t Type, err error) *Exception

func (Annotator) Unimplemented

func (f Annotator) Unimplemented(err error) *Exception

func (Annotator) WrapDisconnected

func (f Annotator) WrapDisconnected(msg string, err error) *Exception

func (Annotator) WrapFailed

func (f Annotator) WrapFailed(msg string, err error) *Exception

func (Annotator) WrapUnimplemented

func (f Annotator) WrapUnimplemented(msg string, err error) *Exception

type Exception

type Exception struct {
	Type   Type
	Prefix string
	Cause  error
}

Exception is an error that designates a Cap'n Proto exception.

func Annotate

func Annotate(prefix, msg string, err error) *Exception

Annotate creates a new error that formats as "<prefix>: <msg>: <err>". If err has the same prefix, then the prefix won't be duplicated. The returned error's type will match err's type.

func New

func New(typ Type, prefix, msg string) *Exception

New creates a new error that formats as "<prefix>: <msg>". The type can be recovered using the TypeOf() function.

func (Exception) Annotate

func (e Exception) Annotate(prefix, msg string) *Exception

Annotate is creates a new error that formats as "<prefix>: <msg>: <e>". If e.Prefix == prefix, the prefix will not be duplicated. The returned Error.Type == e.Type.

func (Exception) Error

func (e Exception) Error() string

func (Exception) GoString

func (e Exception) GoString() string

func (Exception) Unwrap

func (e Exception) Unwrap() error

type Type

type Type int

Type indicates the type of error, mirroring those in rpc.capnp.

const (
	Failed        Type = 0
	Overloaded    Type = 1
	Disconnected  Type = 2
	Unimplemented Type = 3
)

Error types.

func TypeOf

func TypeOf(err error) Type

TypeOf returns err's type if err was created by this package or Failed if it was not.

func (Type) GoString

func (typ Type) GoString() string

GoString returns the Go constant name, or a string in the form "Type(X)" where X is the value of typ for any unrecognized type.

func (Type) String

func (typ Type) String() string

String returns the lowercased Go constant name, or a string in the form "type(X)" where X is the value of typ for any unrecognized type.

Jump to

Keyboard shortcuts

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