Documentation
¶
Overview ¶
Package errors provides error creation and matching for all wallet systems. It is imported as errors and takes over the roll of the standard library errors package.
Index ¶
- Variables
- func E(args ...interface{}) error
- func Errorf(format string, args ...interface{}) error
- func Is(kind Kind, err error) bool
- func Match(err1, err2 error) bool
- func MatchAll(needle, haystack error) bool
- func New(text string) error
- func Stacks(err error) [][]byte
- func WithStack(args ...interface{}) error
- type Error
- type Kind
- type Op
Constants ¶
This section is empty.
Variables ¶
var Separator = ":\n\t"
Separator is inserted between nested errors when formatting as strings. The default separator produces easily readable multiline errors. Separator may be modified at init time to create error strings appropiate for logging errors on a single line.
Functions ¶
func E ¶
func E(args ...interface{}) error
E creates an *Error from one or more arguments.
Each argument type is inspected when constructing the error. If multiple args of similar type are passed, the final arg is recorded. The following types are recognized:
errors.Op The operation, method, or RPC which was invoked. errors.Kind The class of error. string Description of the error condition. String types populate the Err field and overwrite, and are overwritten by, other arguments which implement the error interface. error The underlying error. If the error is an *Error, the Op and Kind will be promoted to the newly created error if not set to another value in the args.
If another *Error is passed as an argument and no other arguments differ from the wrapped error, instead of wrapping the error, the errors are collapsed and fields of the passed *Error are promoted to the returned error.
Panics if no arguments are passed.
func Errorf ¶
Errorf creates a simple error from a format string and arguments. Errorf is identical to "fmt".Errorf from the standard library.
func Is ¶
Is returns whether err is of type *Error and has a matching kind in err or any nested errors. Does not match against the Other kind.
func Match ¶
Match compares two Errors, returning true if every non-zero field of err1 is equal to the same field in err2. Nested errors in err1 are similarly compared to any nested error of err2.
func MatchAll ¶
MatchAll performs Match on needle using haystack and every nested error of haystack.
func New ¶
New creates a simple error from a string. New is identical to "errors".New from the standard library.
Types ¶
type Error ¶
Error describes an error condition raised within the wallet process. Errors may optionally provide details regarding the operation and class of error for assistance in debugging and runtime matching of errors.
type Kind ¶
type Kind int
Kind describes the class of error.
const ( Other Kind = iota // Unclassified error -- does not appear in error strings Bug // Error is known to be a result of our bug Invalid // Invalid operation Permission // Permission denied IO // I/O error Exist // Item already exists NotExist // Item does not exist Encoding // Invalid encoding Crypto // Encryption or decryption error Locked // Wallet is locked Passphrase // Invalid passphrase Seed // Invalid seed WatchingOnly // Missing private keys InsufficientBalance // Insufficient balance to create transaction (perhaps due to UTXO selection requirements) ScriptFailure // Transaction scripts do not execute (usually due to missing sigs) Policy // Transaction rejected by wallet policy Consensus // Consensus violation DoubleSpend // Transaction is a double spend Protocol // Protocol violation NoPeers // Decred network is unreachable due to lack of peers or pfcd RPC connections Deployment // Inactive consensus deployment )
Error kinds.