tx_indexer/
error.rs

1/// Specify what the indexer event handler should do for specific errors. See: `ErrorPolicyProvider`.
2/// The idea is that an error type, `E`, implements `ErrorPolicyProvider`.
3/// Based on the different variants of `E`, different `ErrorPolicy` can be returned, which influences
4/// the behavior of the event handler.
5pub enum ErrorPolicy<E> {
6    /// Indicate the callback operation should be retried. Also see: `RetryPolicy`.
7    Retry,
8    /// Indicate that the error should be ignored, go to next event.
9    Skip,
10    /// Indicate that the event handler should exit with error.
11    Exit,
12    /// Indicate that the event handler should call given error handling function with the error.
13    Call(fn(E) -> ()),
14}
15
16/// Trait that can be implemented for custom error types.
17/// Different variants in said error types can then be given different `ErrorPolicy` assignments.
18pub trait ErrorPolicyProvider
19where
20    Self: Sized,
21{
22    fn get_error_policy(&self) -> ErrorPolicy<Self>;
23}