Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInternal represents a general case issue that cannot be // categorized as any of the below cases. // We start as 1 as 0 is reserved for non-errors ErrInternal = Register(1, "internal") // authorization is handled. ErrUnauthorized = Register(2, "unauthorized") // ErrNotFound is used when a requested operation cannot be completed // due to missing data. ErrNotFound = Register(3, "not found") // ErrInvalidMsg is returned whenever an event is invalid and cannot be // handled. ErrInvalidMsg = Register(4, "invalid message") // ErrInvalidModel is returned whenever a message is invalid and cannot // be used (ie. persisted). ErrInvalidModel = Register(5, "invalid model") // ErrDuplicate is returned when there is a record already that has the same // unique key/index used ErrDuplicate = Register(6, "duplicate") // ErrHuman is returned when application reaches a code path which should not // ever be reached if the code was written as expected by the framework ErrHuman = Register(7, "coding error") // ErrCannotBeModified is returned when something that is considered immutable // gets modified ErrCannotBeModified = Register(8, "cannot be modified") // ErrEmpty is returned when a value fails a not empty assertion ErrEmpty = Register(9, "value is empty") // ErrInvalidState is returned when an object is in invalid state ErrInvalidState = Register(10, "invalid state") // ErrInvalidType is returned whenever the type is not what was expected ErrInvalidType = Register(11, "invalid type") // ErrInsufficientAmount is returned when an amount of currency is insufficient, e.g. funds/fees ErrInsufficientAmount = Register(12, "insufficient amount") // ErrInvalidAmount stands for invalid amount of whatever ErrInvalidAmount = Register(13, "invalid amount") // ErrInvalidInput stands for general input problems indication ErrInvalidInput = Register(14, "invalid input") // ErrExpired stands for expired entities, normally has to do with block height expirations ErrExpired = Register(15, "expired") // ErrOverflow s returned when a computation cannot be completed // because the result value exceeds the type. ErrOverflow = Register(16, "an operation cannot be completed due to value overflow") // ErrPanic is only set when we recover from a panic, so we know to redact potentially sensitive system info ErrPanic = Register(111222, "panic") )
Global error registry, codes 1-99 are reserved for global errors, 0 is reserved for non-errors
Functions ¶
func NormalizePanic ¶
func NormalizePanic(p interface{}) error
NormalizePanic converts a panic into a redacted error
We want the whole stack trace for logging but should show nothing over the ABCI interface....
func Recover ¶
func Recover(err *error)
Recover takes a pointer to the returned error, and sets it upon panic
Types ¶
type Error ¶ added in v0.12.0
type Error struct {
// contains filtered or unexported fields
}
Error represents a root error.
Weave framework is using root error to categorize issues. Each instance created during the runtime should wrap one of the declared root errors. This allows error tests and returning all errors to the client in a safe manner.
All popular root errors are declared in this package. If an extension has to declare a custom root error, always use Register function to ensure error code uniqueness.
func Register ¶ added in v0.12.0
Register returns an error instance that should be used as the base for creating error instances during runtime.
Popular root errors are declared in this package, but extensions may want to declare custom codes. This function ensures that no error code is used twice. Attempt to reuse an error code results in panic.
Use this function only during a program startup phase.
func (*Error) Is ¶ added in v0.12.0
Is check if given error instance is of a given kind/type. This involves unwrapping given error using the Cause method if available.
Any non weave implementation of an error is tested positive for being ErrInternal.
type TMError ¶
type TMError interface { ABCICode() uint32 ABCILog() string // contains filtered or unexported methods }
TMError is the tendermint abci return type with stack trace
func Wrap ¶
Wrap extends given error with an additional information.
If the wrapped error does not provide ABCICode method (ie. stdlib errors), it will be labeled as internal error.
If err is nil, this returns nil, avoiding the need for an if statement when wrapping a error returned at the end of a function