Struct devol_accounts_kit::dvl_error::DvlError
source · pub struct DvlError { /* private fields */ }Implementations§
source§impl DvlError
impl DvlError
sourcepub fn new_with_account(account: AccountTag, error: ContractError) -> Self
pub fn new_with_account(account: AccountTag, error: ContractError) -> Self
Creates a new ContractErrorDetails with a specified error and associated account.
sourcepub fn new(error: ContractError) -> Self
pub fn new(error: ContractError) -> Self
Creates a new ContractErrorDetails with a specified error without associating an account.
sourcepub fn encode(&self) -> u32
pub fn encode(&self) -> u32
Encodes the error details into a 32-bit integer for on-chain error handling.
The error code is a 32-bit unsigned integer where:
- The most significant bit (MSB) is always set to 1 to indicate a new error system.
- The next 3 bits (from MSB) are reserved for future use and are currently set to 0.
- The following 8 bits represent the account identifier if provided, or are set to 0.
- The least significant 16 bits represent the
ContractErrorcode.
§Arguments
error- AContractErrorenumeration representing the specific error.account- An optionalAccountenumeration representing the account involved in the error, if applicable.
§Returns
A 32-bit unsigned integer encoding the error and account information according to the rules described.
§Layout
31 30 29 25 24 16 15 0 +––+––+—––+——————————+––––––––––––––––+ | 1 | A | 0 0 0 | Account ID (if provided) | ContractError Code | +––+––+—––+——————————+––––––––––––––––+
1 = MSB, always set to indicate a new error system. A = Account-related flag (set to 1 if the error is account-specific, 0 otherwise). Reserved = Currently unused bits, set to 0. Account ID = 8-bit identifier for the account, shifted into bits 23 through 16. ContractError Code = 16-bit error code, occupying the least significant bits.
pub fn from_code(code: u32) -> Self
Trait Implementations§
source§impl Error for DvlError
impl Error for DvlError
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
impl Copy for DvlError
Auto Trait Implementations§
impl Freeze for DvlError
impl RefUnwindSafe for DvlError
impl Send for DvlError
impl Sync for DvlError
impl Unpin for DvlError
impl UnwindSafe for DvlError
Blanket Implementations§
source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more