at protocol indexer with flexible filtering, xrpc queries, and a cursor-backed event stream, built on fjall
at-protocol atproto indexer rust fjall

[backfill] refactor BackfillError to use thiserror

ptr.pet 12afce18 8c239314

verified
+6 -12
+6 -12
src/backfill/mod.rs
··· 12 12 use jacquard_common::xrpc::XrpcError; 13 13 use jacquard_repo::mst::Mst; 14 14 use jacquard_repo::{BlockStore, MemoryBlockStore}; 15 - use miette::{IntoDiagnostic, Result}; 15 + use miette::{Diagnostic, IntoDiagnostic, Result}; 16 16 use reqwest::StatusCode; 17 17 use smol_str::{SmolStr, ToSmolStr}; 18 18 use std::collections::HashMap; 19 - use std::fmt::Display; 20 19 use std::sync::Arc; 21 20 use std::sync::atomic::Ordering; 22 21 use std::time::{Duration, Instant}; 22 + use thiserror::Error; 23 23 use tokio::sync::Semaphore; 24 24 use tracing::{debug, error, info, trace, warn}; 25 25 ··· 293 293 Ok(()) 294 294 } 295 295 296 + #[derive(Debug, Diagnostic, Error)] 296 297 enum BackfillError { 298 + #[error("{0}")] 297 299 Generic(miette::Report), 300 + #[error("too many requests")] 298 301 Ratelimited, 302 + #[error("transport error: {0}")] 299 303 Transport(SmolStr), 300 304 } 301 305 ··· 318 322 impl From<miette::Report> for BackfillError { 319 323 fn from(e: miette::Report) -> Self { 320 324 Self::Generic(e) 321 - } 322 - } 323 - 324 - impl Display for BackfillError { 325 - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 326 - match self { 327 - BackfillError::Generic(e) => e.fmt(f), 328 - BackfillError::Ratelimited => write!(f, "too many requests"), 329 - BackfillError::Transport(reason) => write!(f, "transport error: {reason}"), 330 - } 331 325 } 332 326 } 333 327