errors

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknown defines an unknown error, if this is returned it means
	// the library is ignoring an error
	ErrUnknown = RegisterError(0, "unknown", false, "unknown error")
	// ErrOffline is returned when there is an attempt to query an endpoint in offline mode
	ErrOffline = RegisterError(1, "cannot query endpoint in offline mode", false, "returned when querying an online endpoint in offline mode")
	// ErrNetworkNotSupported is returned when there is an attempt to query a network which is not supported
	ErrNetworkNotSupported = RegisterError(2, "network is not supported", false, "returned when querying a non supported network")
	// ErrCodec is returned when there's an error while marshalling or unmarshalling data
	ErrCodec = RegisterError(3, "encode/decode error", true, "returned when there are errors encoding or decoding information to and from the node")
	// ErrInvalidOperation is returned when the operation supplied to rosetta is not a valid one
	ErrInvalidOperation = RegisterError(4, "invalid operation", false, "returned when the operation is not valid")
	// ErrInvalidTransaction is returned when the provided hex bytes of a TX are not valid
	ErrInvalidTransaction = RegisterError(5, "invalid transaction", false, "returned when the transaction is invalid")
	// ErrInvalidAddress is returned when the byte of the address are bad
	ErrInvalidAddress = RegisterError(7, "invalid address", false, "returned when the address is malformed")
	// ErrInvalidPubkey is returned when the public key is invalid
	ErrInvalidPubkey = RegisterError(8, "invalid pubkey", false, "returned when the public key is invalid")
	// ErrInterpreting is returned when there are errors interpreting the data from the node, most likely related to breaking changes, version incompatibilities
	ErrInterpreting = RegisterError(9, "error interpreting data from node", false, "returned when there are issues interpreting requests or response from node")
	ErrInvalidMemo  = RegisterError(11, "invalid memo", false, "returned when the memo is invalid")
	// ErrBadArgument is returned when the request is malformed
	ErrBadArgument = RegisterError(400, "bad argument", false, "request is malformed")
	// ErrNotFound is returned when the required object was not found
	// retry is set to true because something that is not found now
	// might be found later, example: a TX
	ErrNotFound = RegisterError(404, "not found", true, "returned when the node does not find what the client is asking for")
	// ErrInternal is returned when the node is experiencing internal errors
	ErrInternal = RegisterError(500, "internal error", false, "returned when the node experiences internal errors")
	// ErrBadGateway is returned when there are problems interacting with the nodes
	ErrBadGateway = RegisterError(502, "bad gateway", true, "return when the node is unreachable")
	// ErrNotImplemented is returned when a method is not implemented yet
	ErrNotImplemented = RegisterError(14, "not implemented", false, "returned when querying an endpoint which is not implemented")
	// ErrUnsupportedCurve is returned when the curve specified is not supported
	ErrUnsupportedCurve = RegisterError(15, "unsupported curve, expected secp256k1", false, "returned when using an unsupported crypto curve")
)

Default error list

Functions

func ListErrors

func ListErrors() []*types.Error

ListErrors lists all the registered errors

func SealAndListErrors

func SealAndListErrors() []*types.Error

SealAndListErrors seals the registry and lists its errors

func ToRosetta

func ToRosetta(err error) *types.Error

ToRosetta attempts to converting an error into a rosetta error, if the error cannot be converted it will be parsed as unknown

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error defines an error that can be converted to a Rosetta API error.

func FromGRPCToRosettaError

func FromGRPCToRosettaError(err error) *Error

FromGRPCToRosettaError converts a gRPC error to rosetta error

func RegisterError

func RegisterError(code int32, message string, retryable bool, description string) *Error

func WrapError

func WrapError(err *Error, msg string) *Error

WrapError wraps the rosetta error with additional context

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(err error) bool

Is implements errors.Is for *Error, two errors are considered equal if their error codes are identical

Jump to

Keyboard shortcuts

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