exitcode

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: Apache-2.0, MIT Imports: 4 Imported by: 59

Documentation

Index

Constants

View Source
const (
	// Indicates a method parameter is invalid.
	ErrIllegalArgument = FirstActorErrorCode + iota
	// Indicates a requested resource does not exist.
	ErrNotFound
	// Indicates an action is disallowed.
	ErrForbidden
	// Indicates a balance of funds is insufficient.
	ErrInsufficientFunds
	// Indicates an actor's internal state is invalid.
	ErrIllegalState
	// Indicates de/serialization failure within actor code.
	ErrSerialization

	// Common error codes stop here.  If you define a common error code above
	// this value it will have conflicting interpretations
	FirstActorSpecificExitCode = ExitCode(32)
)
View Source
const (
	Ok = ExitCode(0)

	// Indicates that the actor identified as the sender of a message is not valid as a message sender:
	// - not present in the state tree
	// - not an account actor (for top-level messages)
	// - code CID is not found or invalid
	// (not found in the state tree, not an account, has no code).
	SysErrSenderInvalid = ExitCode(1)

	// Indicates that the sender of a message is not in a state to send the message:
	// - invocation out of sequence (mismatched CallSeqNum)
	// - insufficient funds to cover execution
	SysErrSenderStateInvalid = ExitCode(2)

	// Indicates failure to find a method in an actor.
	SysErrInvalidMethod = ExitCode(3)

	// Unused.
	SysErrReserved1 = ExitCode(4)

	// Indicates that the receiver of a message is not valid (and cannot be implicitly created).
	SysErrInvalidReceiver = ExitCode(5)

	// Indicates that a message sender has insufficient balance for the value being sent.
	// Note that this is distinct from SysErrSenderStateInvalid when a top-level sender can't cover
	// value transfer + gas. This code is only expected to come from inter-actor sends.
	SysErrInsufficientFunds = ExitCode(6)

	// Indicates message execution (including subcalls) used more gas than the specified limit.
	SysErrOutOfGas = ExitCode(7)

	// Indicates message execution is forbidden for the caller by runtime caller validation.
	SysErrForbidden = ExitCode(8)

	// Indicates actor code performed a disallowed operation. Disallowed operations include:
	// - mutating state outside of a state acquisition block
	// - failing to invoke caller validation
	// - aborting with a reserved exit code (including success or a system error).
	SysErrorIllegalActor = ExitCode(9)

	// Indicates an invalid argument passed to a runtime method.
	SysErrorIllegalArgument = ExitCode(10)

	// Unused
	SysErrReserved2 = ExitCode(11)
	SysErrReserved3 = ExitCode(12)
	SysErrReserved4 = ExitCode(13)
	SysErrReserved5 = ExitCode(14)
	SysErrReserved6 = ExitCode(15)
)

The system error codes are reserved for use by the runtime. No actor may use one explicitly. Correspondingly, no runtime invocation should abort with an exit code outside this list. We could move these definitions out of this package and into the runtime spec.

View Source
const FirstActorErrorCode = ExitCode(16)

The initial range of exit codes is reserved for system errors. Actors may define codes starting with this one.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExitCode

type ExitCode int64

func Unwrap

func Unwrap(err error, defaultExitCode ExitCode) (code ExitCode)

Unwrap extracts an exit code from an error, defaulting to the passed default exit code.

err := ErrIllegalState.WithContext("my description: %w", err)
exitcode.Unwrap(exitcode.ErrIllegalState, err) == exitcode.ErrIllegalArgument

func (ExitCode) Error

func (x ExitCode) Error() string

Implement error to trigger Go compiler checking of exit code return values.

func (ExitCode) IsError

func (x ExitCode) IsError() bool

func (ExitCode) IsSendFailure

func (x ExitCode) IsSendFailure() bool

Whether an exit code indicates a message send failure. A send failure means that the caller's CallSeqNum is not incremented and the caller has not paid gas fees for the message (because the caller doesn't exist or can't afford it). A receipt with send failure does not indicate that the message (or another one carrying the same CallSeqNum) could not apply in the future, against a different state.

func (ExitCode) IsSuccess

func (x ExitCode) IsSuccess() bool

func (ExitCode) String

func (x ExitCode) String() string

A non-canonical string representation for human inspection.

func (ExitCode) Wrapf

func (x ExitCode) Wrapf(msg string, args ...interface{}) error

Wrapf attaches an error message, and possibly an error, to the exit code.

err := ErrIllegalArgument.Wrapf("my description: %w", err)
exitcode.Unwrap(exitcode.ErrIllegalState, err) == exitcode.ErrIllegalArgument

Jump to

Keyboard shortcuts

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