Enum casper_types::ApiError [−][src]
Errors which can be encountered while running a smart contract.
An ApiError
can be converted to a u32
in order to be passed via the execution engine’s
ext_ffi::casper_revert()
function. This means the information each variant can convey is
limited.
The variants are split into numeric ranges as follows:
Inclusive range | Variant(s) |
---|---|
[1, 64511] | all except reserved system contract error ranges defined below. |
[64512, 64767] | Auction |
[64768, 65023] | ContractHeader |
[65024, 65279] | Mint |
[65280, 65535] | HandlePayment |
[65536, 131071] | User |
Mappings
The expanded mapping of all variants to their numerical equivalents is as follows:
// General system errors: 1 => None 2 => MissingArgument 3 => InvalidArgument 4 => Deserialize 5 => Read 6 => ValueNotFound 7 => ContractNotFound 8 => GetKey 9 => UnexpectedKeyVariant 10 => UnexpectedContractRefVariant 11 => InvalidPurseName 12 => InvalidPurse 13 => UpgradeContractAtURef 14 => Transfer 15 => NoAccessRights 16 => CLTypeMismatch 17 => EarlyEndOfStream 18 => Formatting 19 => LeftOverBytes 20 => OutOfMemory 21 => MaxKeysLimit 22 => DuplicateKey 23 => PermissionDenied 24 => MissingKey 25 => ThresholdViolation 26 => KeyManagementThreshold 27 => DeploymentThreshold 28 => InsufficientTotalWeight 29 => InvalidSystemContract 30 => PurseNotCreated 31 => Unhandled 32 => BufferTooSmall 33 => HostBufferEmpty 34 => HostBufferFull // Auction errors: use casper_types::system::auction::Error as AuctionError; 64_512 => AuctionError::MissingKey 64_513 => AuctionError::InvalidKeyVariant 64_514 => AuctionError::MissingValue 64_515 => AuctionError::Serialization 64_516 => AuctionError::TransferToBidPurse 64_517 => AuctionError::InvalidAmount 64_518 => AuctionError::BidNotFound 64_519 => AuctionError::ValidatorNotFound 64_520 => AuctionError::DelegatorNotFound 64_521 => AuctionError::Storage 64_522 => AuctionError::Bonding 64_523 => AuctionError::Unbonding 64_524 => AuctionError::ReleaseFounderStake 64_525 => AuctionError::GetBalance 64_526 => AuctionError::InvalidContext 64_527 => AuctionError::ValidatorFundsLocked 64_528 => AuctionError::InvalidCaller 64_529 => AuctionError::InvalidPublicKey 64_530 => AuctionError::BondNotFound 64_531 => AuctionError::CreatePurseFailed 64_532 => AuctionError::UnbondTooLarge 64_533 => AuctionError::BondTooSmall 64_534 => AuctionError::MissingDelegations 64_535 => AuctionError::MismatchedEraValidators 64_536 => AuctionError::MintReward 64_537 => AuctionError::InvalidValidatorSlotsValue 64_538 => AuctionError::MintReduceTotalSupply 64_539 => AuctionError::TransferToDelegatorPurse 64_540 => AuctionError::ValidatorRewardTransfer 64_541 => AuctionError::DelegatorRewardTransfer 64_542 => AuctionError::WithdrawDelegatorReward 64_543 => AuctionError::WithdrawValidatorReward 64_544 => AuctionError::TransferToUnbondingPurse // Contract header errors: use casper_types::contracts::Error as ContractHeaderError; 64_769 => ContractHeaderError::PreviouslyUsedVersion 64_770 => ContractHeaderError::ContractNotFound 64_771 => ContractHeaderError::GroupAlreadyExists 64_772 => ContractHeaderError::MaxGroupsExceeded 64_773 => ContractHeaderError::MaxTotalURefsExceeded // Mint errors: use casper_types::system::mint::Error as MintError; 65_024 => MintError::InsufficientFunds 65_025 => MintError::SourceNotFound 65_026 => MintError::DestNotFound 65_027 => MintError::InvalidURef 65_028 => MintError::InvalidAccessRights 65_029 => MintError::InvalidNonEmptyPurseCreation 65_030 => MintError::Storage 65_031 => MintError::PurseNotFound // Handle Payment errors: use casper_types::system::handle_payment::Error as PosError; 65_280 => PosError::NotBonded 65_281 => PosError::TooManyEventsInQueue 65_282 => PosError::CannotUnbondLastValidator 65_283 => PosError::SpreadTooHigh 65_284 => PosError::MultipleRequests 65_285 => PosError::BondTooSmall 65_286 => PosError::BondTooLarge 65_287 => PosError::UnbondTooLarge 65_288 => PosError::BondTransferFailed 65_289 => PosError::UnbondTransferFailed 65_290 => PosError::TimeWentBackwards 65_291 => PosError::StakesNotFound 65_292 => PosError::PaymentPurseNotFound 65_293 => PosError::PaymentPurseKeyUnexpectedType 65_294 => PosError::PaymentPurseBalanceNotFound 65_295 => PosError::BondingPurseNotFound 65_296 => PosError::BondingPurseKeyUnexpectedType 65_297 => PosError::RefundPurseKeyUnexpectedType 65_298 => PosError::RewardsPurseNotFound 65_299 => PosError::RewardsPurseKeyUnexpectedType 65_300 => PosError::StakesKeyDeserializationFailed 65_301 => PosError::StakesDeserializationFailed 65_302 => PosError::SystemFunctionCalledByUserAccount 65_303 => PosError::InsufficientPaymentForAmountSpent 65_304 => PosError::FailedTransferToRewardsPurse 65_305 => PosError::FailedTransferToAccountPurse 65_306 => PosError::SetRefundPurseCalledOutsidePayment // User-defined errors: 65_536 => User(0) 65_537 => User(1) 65_538 => User(2) 131_071 => User(u16::max_value())
Users can specify a C-style enum and implement From
to ease usage of
casper_contract::runtime::revert()
, e.g.
use casper_types::ApiError; #[repr(u16)] enum FailureCode { Zero = 0, // 65,536 as an ApiError::User One, // 65,537 as an ApiError::User Two // 65,538 as an ApiError::User } impl From<FailureCode> for ApiError { fn from(code: FailureCode) -> Self { ApiError::User(code as u16) } } assert_eq!(ApiError::User(1), FailureCode::One.into()); assert_eq!(65_536, u32::from(ApiError::from(FailureCode::Zero))); assert_eq!(65_538, u32::from(ApiError::from(FailureCode::Two)));
Variants
Optional data was unexpectedly None
.
Specified argument not provided.
Argument not of correct type.
Failed to deserialize a value.
casper_contract::storage::read()
returned an error.
The given key returned a None
value.
Failed to find a specified contract.
A call to casper_contract::runtime::get_key()
returned a failure.
The Key
variant was not as expected.
Obsolete error variant (we no longer have ContractRef).
Invalid purse name given.
Invalid purse retrieved.
Failed to upgrade contract at URef
.
Failed to transfer motes.
The given URef
has no access rights.
A given type could not be constructed from a CLValue
.
Early end of stream while deserializing.
Formatting error while deserializing.
Not all input bytes were consumed in deserialize
.
Out of memory error.
There are already MAX_ASSOCIATED_KEYS
AccountHash
s associated with the given account.
The given AccountHash
is already associated with the given
account.
Caller doesn’t have sufficient permissions to perform the given action.
The given AccountHash
is not associated with the given
account.
Removing/updating the given associated AccountHash
would
cause the total Weight
of all remaining AccountHash
s to
fall below one of the action thresholds for the given account.
Setting the key-management threshold to a value lower than the deployment threshold is disallowed.
Setting the deployment threshold to a value greater than any other threshold is disallowed.
Setting a threshold to a value greater than the total weight of associated keys is disallowed.
The given u32
doesn’t map to a SystemContractType
.
Failed to create a new purse.
An unhandled value, likely representing a bug in the code.
The provided buffer is too small to complete an operation.
No data available in the host buffer.
The host buffer has been set to a value and should be consumed first by a read operation.
Could not lay out an array in memory
AuctionError(u8)
Error specific to Auction contract.
ContractHeader(u8)
Contract header errors.
Mint(u8)
Error specific to Mint contract.
HandlePayment(u8)
Error specific to Handle Payment contract.
User(u16)
User-specified error code. The internal u16
value is added to u16::MAX as u32 + 1
when
an Error::User
is converted to a u32
.
Trait Implementations
impl Clone for ApiError
[src]
impl Copy for ApiError
[src]
impl Debug for ApiError
[src]
impl Display for ApiError
[src]
impl Eq for ApiError
[src]
impl From<AddKeyFailure> for ApiError
[src]
fn from(error: AddKeyFailure) -> Self
[src]
impl From<CLValueError> for ApiError
[src]
fn from(error: CLValueError) -> Self
[src]
impl From<Error> for ApiError
[src]
impl From<Error> for ApiError
[src]
impl From<Error> for ApiError
[src]
impl From<Error> for ApiError
[src]
impl From<Error> for ApiError
[src]
impl From<RemoveKeyFailure> for ApiError
[src]
fn from(error: RemoveKeyFailure) -> Self
[src]
impl From<SetThresholdFailure> for ApiError
[src]
fn from(error: SetThresholdFailure) -> Self
[src]
impl From<TryFromSliceForAccountHashError> for ApiError
[src]
fn from(_error: TryFromSliceForAccountHashError) -> Self
[src]
impl From<UpdateKeyFailure> for ApiError
[src]
fn from(error: UpdateKeyFailure) -> Self
[src]
impl From<u32> for ApiError
[src]
impl PartialEq<ApiError> for ApiError
[src]
impl StructuralEq for ApiError
[src]
impl StructuralPartialEq for ApiError
[src]
Auto Trait Implementations
impl RefUnwindSafe for ApiError
impl Send for ApiError
impl Sync for ApiError
impl Unpin for ApiError
impl UnwindSafe for ApiError
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Conv for T
impl<T> FmtForward for T
pub fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
Self: Binary,
pub fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
Self: Display,
pub fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
Self: LowerExp,
pub fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
Self: LowerHex,
pub fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
Self: Octal,
pub fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
Self: Pointer,
pub fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
Self: UpperExp,
pub fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
Self: UpperHex,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pipe for T
impl<T> PipeAsRef for T
pub fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
R: 'a,
T: 'a,
Self: AsRef<T>,
R: 'a,
T: 'a,
pub fn pipe_as_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: AsMut<T>,
R: 'a,
T: 'a,
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: AsMut<T>,
R: 'a,
T: 'a,
impl<T> PipeBorrow for T
pub fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
R: 'a,
T: 'a,
Self: Borrow<T>,
R: 'a,
T: 'a,
pub fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: BorrowMut<T>,
R: 'a,
T: 'a,
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: BorrowMut<T>,
R: 'a,
T: 'a,
impl<T> PipeDeref for T
pub fn pipe_deref<'a, R>(
&'a self,
func: impl FnOnce(&'a Self::Target) -> R
) -> R where
Self: Deref,
R: 'a,
&'a self,
func: impl FnOnce(&'a Self::Target) -> R
) -> R where
Self: Deref,
R: 'a,
pub fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
Self: DerefMut,
R: 'a,
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
Self: DerefMut,
R: 'a,
impl<T> PipeRef for T
pub fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
R: 'a,
pub fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
R: 'a,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> Tap for T
pub fn tap<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
F: FnOnce(&Self) -> R,
pub fn tap_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
F: FnOnce(&Self) -> R,
pub fn tap_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
F: FnOnce(&mut Self) -> R,
pub fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
F: FnOnce(&mut Self) -> R,
impl<T, U> TapAsRef<U> for T where
U: ?Sized,
U: ?Sized,
pub fn tap_ref<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Self: AsRef<T>,
F: FnOnce(&T) -> R,
pub fn tap_ref_dbg<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Self: AsRef<T>,
F: FnOnce(&T) -> R,
pub fn tap_ref_mut<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
pub fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
impl<T, U> TapBorrow<U> for T where
U: ?Sized,
U: ?Sized,
pub fn tap_borrow<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Self: Borrow<T>,
F: FnOnce(&T) -> R,
pub fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Self: Borrow<T>,
F: FnOnce(&T) -> R,
pub fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
pub fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
impl<T> TapDeref for T
pub fn tap_deref<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Self: Deref,
F: FnOnce(&Self::Target) -> R,
pub fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Self: Deref,
F: FnOnce(&Self::Target) -> R,
pub fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
pub fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> TryConv for T
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,