Package errors implements errors that can be easily sent across the wire and reconstructed at the other end.



const (
	// UnknownModule is the module name used when the module is unknown.
	UnknownModule = "unknown"

	// CodeNoError is the reserved "no error" code.
	CodeNoError = 0


var (
	As     = errors.As
	Is     = errors.Is
	Unwrap = errors.Unwrap

Re-exports so this package can be used as a replacement for errors.


func Code

func Code(err error) (string, uint32)

Code returns the module and code for the given error.

In case the error is not of the correct type, default values for an unknown error are returned.

func FromCode

func FromCode(module string, code uint32) error

FromCode reconstructs a previously registered error from module and code.

In case an error cannot be resolved, this method returns nil.

func New

func New(module string, code uint32, msg string) error

New creates a new error.

Module and code pair must be unique. If they are not, this method will panic.

The error code must not be equal to the reserved "no error" code.


This section is empty.

Source Files