Skip to content

Define top-level basecoin error type #186

Open
@seanchen1991

Description

Following along with the theme of improving error-handling in ibc-rs, we should define a top-level error type in basecoin that will serve as basecoin's host error type for when basecoin errors need to be propagated and handled by ibc-rs.

@rnbguy's example suggestion:

impl<S> ClientValidationContext for IbcContext<S>
where
    S: Store + Debug,
{
    type HostError = BasecoinError<S>;
    
    ...
}

impl<S> ClientExecutionContext for IbcContext<S>
where
    S: Store + Debug,
{
    fn store_client_state(
        &mut self,
        client_state_path: ClientStatePath,
        client_state: Self::ClientStateMut,
    ) -> Result<(), ContextError<Self::HostError<S>>> {
        self.client_state_store
            .set(client_state_path, client_state)
            .map(|_| ())
            // currently, we forget about the actual host error
            // and just do:
            // .map_err(|_| ClientError::Other { ... })
            .map_err(|err| ClientError::Generic(GenericError::Host(err)))?
        Ok(())
    }
    ...
}

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions