- I am using ink! to implement the contract.
- I have implemented my own error, and the contract function has this own error as a return value.
- For example, suppose that function implements openbrush's Ownable.
- I implemented openbrush's Error implementation as follows.
- What would be the best way to implement it then?
- Referenced source code:https://github.com/Supercolony-net/openbrush-contracts/blob/main/contracts/src/traits/errors/psp37.rs
#[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum MyError {
MyError1,
OwnableErrorCallerIsNotOwner,
OwnableErrorNewOwnerIsZero,
}
impl From<OwnableError> for MyError {
fn from(ownable: OwnableError) -> Self {
match ownable {
OwnableError::CallerIsNotOwner => MyError::OwnableErrorCallerIsNotOwner,
OwnableError::NewOwnerIsZero => MyError::OwnableErrorNewOwnerIsZero,
}
}
}
pub fn function(&self) -> Result<(), MyError> {}
are you talking about something like this? PSP37Error and PSP37Error Implementation