#[derive(SolErrorDecode)]
Expand description
Derives an implementation of ink::sol::SolErrorDecode
for the given struct
or enum
.
§Note
- All field types (if any) must implement [
ink::SolDecode
]. - The error representation derived is a Solidity custom error (or multiple Solidity custom error in the case of an enum, i.e. one for each enum variant).
§Example
use ink_macro::SolErrorDecode;
// Represented as a Solidity custom error with no parameters
#[derive(SolErrorDecode)]
struct UnitError;
// Represented as a Solidity custom error with parameters
#[derive(SolErrorDecode)]
struct ErrorWithParams(bool, u8, String);
// Represented as a Solidity custom error with named parameters
#[derive(SolErrorDecode)]
struct ErrorWithNamedParams {
status: bool,
count: u8,
reason: String,
}
// Represented as multiple Solidity custom errors
// (i.e. each variant represents a Solidity custom error)
#[derive(SolErrorDecode)]
enum MultipleErrors {
UnitError,
ErrorWithParams(bool, u8, String),
ErrorWithNamedParams {
status: bool,
count: u8,
reason: String,
}
}