pub enum Error {
/// too many tribute tokens
ProposalNotFound,
TransferFail(erc20::Erc20::error)
}
+end_src
+begin_src rust
fn sponsor_proposal(&mut self, args: bool) -> Result<(), Error> {
// exit early if input args are not good,
ink_error::ensure!(true, Error::ProposalNotFound);
// panic to revert the state on chain.
ink_error::assert!(true, Error::TransferFail(erc20::Erc20::error:InsuffienceBalances));
// real business logic
Ok(());
The following is the quick note of my roughly idea, gonna be changed later.
+begin_src rust
[ink_error::ink_error_definition]
pub enum SubmitProposalError { /// too many tribute tokens TooManyTributeTokensError }
+end_src
will derive to
+begin_src rust
[derive(displaydoc::Display, Debug, scale::Encode, scale::Decode)]
pub enum Error { /// too many tribute tokens ProposalNotFound, TransferFail(erc20::Erc20::error) }
+end_src
+begin_src rust
fn sponsor_proposal(&mut self, args: bool) -> Result<(), Error> { // exit early if input args are not good, ink_error::ensure!(true, Error::ProposalNotFound);
}
+end_src