exitcode

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0, MIT Imports: 4 Imported by: 287

Documentation

Index

Constants

View Source
const (
	// ErrIllegalArgument indicates that a method parameter is invalid.
	ErrIllegalArgument = FirstActorErrorCode + iota
	// ErrNotFound indicates that a requested resource does not exist.
	ErrNotFound
	// ErrForbidden indicates that an action is disallowed.
	ErrForbidden
	// ErrInsufficientFunds indicates that a balance of funds is insufficient.
	ErrInsufficientFunds
	// ErrIllegalState indicates that an actor's internal state is invalid.
	ErrIllegalState
	// ErrSerialization indicates a de/serialization failure within actor code.
	ErrSerialization
	// ErrUnhandledMessage indicates that the actor cannot handle this message.
	ErrUnhandledMessage
	// ErrUnspecified indicates that the actor failed with an unspecified error.
	ErrUnspecified
	// ErrAssertionFailed indicates that the actor failed a user-level assertion
	ErrAssertionFailed
	// ErrReadOnly indicates that the actor cannot perform the requested operation
	// in read-only mode.
	ErrReadOnly

	// 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 the message receiver trapped (panicked).
	SysErrIllegalInstruction = 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 that message execution (including subcalls) used more gas than the specified
	// limit.
	SysErrOutOfGas = ExitCode(7)

	// Indicates that the actor attempted to exit with a reserved exit code.
	SysErrIllegalExitCode = ExitCode(9)

	// Indicates that something unexpected happened in the system. This always indicates a bug.
	SysErrFatal = ExitCode(10)

	// Indicates the actor returned a block handle that doesn't exist.
	SysErrMissingReturn = ExitCode(11)

	// Unused
	SysErrReserved1 = ExitCode(3)
	SysErrReserved2 = ExitCode(8)
	SysErrReserved3 = ExitCode(12)
	SysErrReserved4 = ExitCode(13)
	SysErrReserved5 = ExitCode(14)
	SysErrReserved6 = ExitCode(15)

	// DEPRECATED
	SysErrInvalidMethod = ExitCode(3)
	// DEPRECATED
	SysErrForbidden = ExitCode(8)
	// DEPRECATED
	SysErrorIllegalActor = ExitCode(9)
	// DEPRECATED
	SysErrorIllegalArgument = ExitCode(10)
)

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