Option type return a custom error?

is it possible for the function Iterator::position to return a custom error when a None is reached? This compiles but i'm not so sure.

pub fn donate (
  proposal_hash: T::Hash
) -> DispatchResult {

  let public_props = PublicProps::<T>::get();
  public_props.iter().position(|p| p == proposal_hash).ok_or(Error::<T>::ProposalMissing)?;

Trying to add a new public function...

What's wrong with the ok_or solution?


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.