#[repr(i32)]pub enum ExitCode {
Show 29 variants
Ok = 0,
Panic = -1,
InterruptionCalled = -3,
RootCallOnly = -1_002,
MalformedBuiltinParams = -1_003,
CallDepthOverflow = -1_004,
NonNegativeExitCode = -1_005,
UnknownError = -1_006,
InputOutputOutOfBounds = -1_007,
PrecompileError = -1_008,
NotSupportedBytecode = -1_009,
StateChangeDuringStaticCall = -1_010,
CreateContractSizeLimit = -1_011,
CreateContractCollision = -1_012,
CreateContractStartingWithEF = -1_013,
OutOfMemory = -1_014,
UnreachableCodeReached = -2_001,
MemoryOutOfBounds = -2_002,
TableOutOfBounds = -2_003,
IndirectCallToNull = -2_004,
IntegerDivisionByZero = -2_005,
IntegerOverflow = -2_006,
BadConversionToInteger = -2_007,
StackOverflow = -2_008,
BadSignature = -2_009,
OutOfFuel = -2_010,
UnknownExternalFunction = -2_011,
UnexpectedFatalExecutionFailure = -3_001,
MissingStorageSlot = -3_002,
}Expand description
Exit codes representing various execution outcomes and error conditions.
This enum defines the possible exit codes that can be returned by the execution environment.
The codes are grouped into several categories:
- Basic status codes (0 to -2)
- Fluentbase-specific error codes (-1000 and below)
- Trap error codes (-2000 and below)
Note: Exit codes cannot be positive, as positive values are used to represent call indices in interrupted executions.
Exit codes are used to represent the outcome of execution across different environments. This makes their interpretation somewhat nuanced.
Within applications, developers can use any exit code, but there are conventions:
Ok(0) — Indicates successful execution.Panic(-1) — Controlled application reverts (intended error, no gas penalty).- Any other code is treated as an error with a gas penalty and is mapped to
Err(-2).
Technically, developers can return trap codes, but it’s generally pointless:
they are replaced by the Err (-2) code and still incur gas penalties.
If the error code cannot be determined, it is mapped to UnknownError (-1006),
which also results in a gas fine.
The SDK provides helper functions such as evm_exit and evm_panic to simplify
returning error codes.
These produce Solidity-compatible error outputs.
The exit function remains available to all developers.
In some cases, an application may want to simulate trap behavior or explicitly exit with a gas
penalty to comply with gas consumption standards (for instance, EVM runtime).
This behavior is similar to Solidity, where only three exit codes are supported:
- For legacy contracts:
Ok = 1,Revert = 0,Err = 2 - For EOF contracts:
Ok = 0,Revert = 1,Err = 2
§Basic Status Codes
Ok(0) - Successful executionPanic(-1) - Execution panicErr(-2) - General error
§Fluentbase Error Codes
RootCallOnly- Operation restricted to root-level callsMalformedBuiltinParams- Invalid parameters passed to builtin functionCallDepthOverflow- Call stack depth exceeded limitNonNegativeExitCode- Exit code must be negativeUnknownError- Unspecified error conditionInputOutputOutOfBounds- I/O operation exceeded boundsPrecompileError- Error in precompiled contract execution
§Trap Error Codes
UnreachableCodeReached- Execution reached unreachable codeMemoryOutOfBounds- Memory access violationTableOutOfBounds- Table access violationIndirectCallToNull- Attempted call to null function pointerIntegerDivisionByZero- Division by zeroIntegerOverflow- Integer overflow occurredBadConversionToInteger- Invalid integer conversionStackOverflow- Stack limit exceededBadSignature- Invalid function signatureOutOfFuel- Insufficient gas/fuel for executionGrowthOperationLimited- Growth operation exceeded limitsUnresolvedFunction- Function not found
Variants§
Ok = 0
Execution is finished without errors
Panic = -1
Panic is produced by a program (aka revert)
InterruptionCalled = -3
An interruption created by runtime (only for system contracts)
RootCallOnly = -1_002
Function can only be invoked as the root entry call
MalformedBuiltinParams = -1_003
Builtin function received malformed or invalid parameters
CallDepthOverflow = -1_004
Exceeded maximum allowed call stack depth
NonNegativeExitCode = -1_005
Exit code must be non-negative, but a negative value was used
UnknownError = -1_006
Generic catch-all error for unknown failures
InputOutputOutOfBounds = -1_007
I/O operation tried to read/write outside allowed buffer bounds
PrecompileError = -1_008
An error happens inside a precompiled contract
NotSupportedBytecode = -1_009
Passed bytecode into executor is not supported
StateChangeDuringStaticCall = -1_010
State changed inside immutable call (static=true)
CreateContractSizeLimit = -1_011
Create a contract size limit reached (limit depends on the application type)
CreateContractCollision = -1_012
There is a collision on the contract creation (the same address is derived)
CreateContractStartingWithEF = -1_013
Created contract starts with invalid bytes (0xEF).
OutOfMemory = -1_014
A program runs out of memory (max memory pages reached)
UnreachableCodeReached = -2_001
Execution reached a code path marked as unreachable
MemoryOutOfBounds = -2_002
Memory access outside the allocated memory range
TableOutOfBounds = -2_003
Table index access outside the allocated table range
IndirectCallToNull = -2_004
Indirect function call attempted with a null function reference
IntegerDivisionByZero = -2_005
Division or remainder by zero occurred
IntegerOverflow = -2_006
Integer arithmetic operation overflowed the allowed range
BadConversionToInteger = -2_007
Invalid conversion to integer (e.g., from NaN or out-of-range value)
StackOverflow = -2_008
Stack reached its limit (overflow or underflow)
BadSignature = -2_009
Function signature mismatch in a call
OutOfFuel = -2_010
Execution ran out of allocated fuel/gas
UnknownExternalFunction = -2_011
Call an undefined or unregistered external function
UnexpectedFatalExecutionFailure = -3_001
An unexpected fatal execution failure (node should panic or terminate the execution)
MissingStorageSlot = -3_002
Missing storage slot
Implementations§
Source§impl ExitCode
impl ExitCode
Sourcepub fn is_trap_code(&self) -> bool
pub fn is_trap_code(&self) -> bool
Check if the exit code represents a trap code
Source§impl ExitCode
impl ExitCode
pub fn is_ok(&self) -> bool
pub fn is_error(&self) -> bool
Sourcepub fn is_fatal_exit_code(&self) -> bool
pub fn is_fatal_exit_code(&self) -> bool
Check if the exit code represents a fatal error
Fatal exit code means that the application terminated unexpectedly, for example, by having out of fuel or memory out of bounds. It means that we can’t handle the output state of this contract gracefully.
pub const fn into_i32(self) -> i32
Trait Implementations§
Source§impl Error for ExitCode
impl Error for ExitCode
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
impl Copy for ExitCode
impl Eq for ExitCode
impl StructuralPartialEq for ExitCode
Auto Trait Implementations§
impl Freeze for ExitCode
impl RefUnwindSafe for ExitCode
impl Send for ExitCode
impl Sync for ExitCode
impl Unpin for ExitCode
impl UnsafeUnpin for ExitCode
impl UnwindSafe for ExitCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.