[][src]Enum casperlabs_contract_ffi::contract_api::Error

pub enum Error {
    None,
    MissingArgument,
    InvalidArgument,
    Deserialize,
    Read,
    ValueNotFound,
    ContractNotFound,
    GetKey,
    UnexpectedKeyVariant,
    UnexpectedValueVariant,
    UnexpectedContractRefVariant,
    InvalidPurseName,
    InvalidPurse,
    UpgradeContractAtURef,
    Transfer,
    NoAccessRights,
    ValueConversion,
    CLTypeMismatch,
    EarlyEndOfStream,
    FormattingError,
    LeftOverBytes,
    OutOfMemoryError,
    MaxKeysLimit,
    DuplicateKey,
    PermissionDenied,
    MissingKey,
    ThresholdViolation,
    KeyManagementThresholdError,
    DeploymentThresholdError,
    PermissionDeniedError,
    InsufficientTotalWeight,
    InvalidSystemContract,
    PurseNotCreated,
    Unhandled,
    BufferTooSmall,
    HostBufferEmpty,
    HostBufferFull,
    Mint(u8),
    ProofOfStake(u8),
    User(u16),
}

Variants to be passed to runtime::revert().

Variants other than Error::User will represent a u32 in the range (0, u16::MAX], while Error::User will represent a u32 in the range (u16::MAX, 2 * u16::MAX + 1].

Users can specify a C-style enum and implement From to ease usage of runtime::revert(), e.g.

use casperlabs_contract_ffi::contract_api::Error;

#[repr(u16)]
enum FailureCode {
    Zero = 0,  // 65,536 as an Error::User
    One,       // 65,537 as an Error::User
    Two        // 65,538 as an Error::User
}

impl From<FailureCode> for Error {
    fn from(code: FailureCode) -> Self {
        Error::User(code as u16)
    }
}

assert_eq!(Error::User(1), FailureCode::One.into());
assert_eq!(65_536, u32::from(Error::from(FailureCode::Zero)));
assert_eq!(65_538, u32::from(Error::from(FailureCode::Two)));

Variants

None

Optional data was unexpectedly None.

MissingArgument

Specified argument not provided.

InvalidArgument

Argument not of correct type.

Deserialize

Failed to deserialize a value.

Read

read returned an error.

ValueNotFound

The given key returned a None value.

ContractNotFound

Failed to find a specified contract.

GetKey

A call to get_key() returned a failure.

UnexpectedKeyVariant

The Key variant was not as expected.

UnexpectedValueVariant

The Value variant was not as expected.

UnexpectedContractRefVariant

The ContractRef variant was not as expected.

InvalidPurseName

Invalid purse name given.

InvalidPurse

Invalid purse retrieved.

UpgradeContractAtURef

Failed to upgrade contract at URef.

Transfer

Failed to transfer motes.

NoAccessRights

No access rights.

ValueConversion

A given type could be derived from a Value.

CLTypeMismatch

A given type could be derived from a CLValue.

EarlyEndOfStream

Early end of stream when deserializing.

FormattingError

Formatting error.

LeftOverBytes

Leftover bytes.

OutOfMemoryError

Out of memory error.

MaxKeysLimit

Unable to add new associated key because maximum amount of keys is reached.

DuplicateKey

Unable to add new associated key because given key already exists.

PermissionDenied

Unable to add/update/remove new associated key due to insufficient permissions.

MissingKey

Unable to update/remove a key that does exist.

ThresholdViolation

Unable to update/remove a key which would violate action threshold constraints.

KeyManagementThresholdError

New threshold should be lower or equal than deployment threshold.

DeploymentThresholdError

New threshold should be lower or equal than key management threshold.

PermissionDeniedError

Unable to set action threshold due to insufficient permissions.

InsufficientTotalWeight

New threshold should be lower or equal than total weight of associated keys.

InvalidSystemContract

Returns when contract tries to obtain URef to a system contract that does not exist.

PurseNotCreated

Failed to create a new purse.

Unhandled

An unhandled value, likely representing a bug in the code.

BufferTooSmall

Passing a buffer of a size that is too small to complete an operation

HostBufferEmpty

No data available in the host buffer.

HostBufferFull

Data in the host buffer is full and should be consumed first by read operation

Mint(u8)

Error specific to Mint contract.

ProofOfStake(u8)

Error specific to Proof of Stake contract.

User(u16)

User-specified value. 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 Error[src]

impl Copy for Error[src]

impl Debug for Error[src]

impl Eq for Error[src]

impl From<AddKeyFailure> for Error[src]

impl From<CLValueError> for Error[src]

impl From<Error> for Error[src]

impl From<Error> for Error[src]

impl From<Error> for Error[src]

impl From<Error> for u32[src]

impl From<RemoveKeyFailure> for Error[src]

impl From<SetThresholdFailure> for Error[src]

impl From<UpdateKeyFailure> for Error[src]

impl PartialEq<Error> for Error[src]

impl StructuralEq for Error[src]

impl StructuralPartialEq for Error[src]

Auto Trait Implementations

impl Send for Error

impl Sync for Error

impl Unpin for Error

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.