0

I have a substrate pallet A and it has following Errors Defined

    #[pallet::error]
    pub enum Error<T> {
        /// Not a coffee
        InvalidCoffee,
    }

trait implementation in Pallet A

pub trait A<AccountId, Error> {
 

    fn is_valid_coffee(coffee_id: u32) -> Result<bool, Error>;
}

impl<T: Config> A<AccountIdOf<T>, Error<T>> for Pallet<T> {
     

     
    fn is_valid_coffee(coffee_id: u32) -> Result<bool, Error<T>> {
        Coffee::<T>::get(coffee_id).ok_or(Error::<T>::InvalidCoffee)
    }
}

I am using a trait defined in this Pallet A (is_valid_coffee) in pallet B, it requires the Error defined in Pallet A. How to import it to Pallet B?

1 Answer 1

4
trait Config: frame_system::Config + another_pallet::Config {}

fn example<T>() -> DispatchError 
where
    T: Config
{
    Err(<another_pallet::Error<T>>::AnotherError)
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.