brk_error
Centralized error handling for the Bitcoin Research Kit
brk_error provides a unified error type and result system used throughout the BRK ecosystem. It consolidates error handling from multiple external dependencies and adds Bitcoin-specific error variants.
What it provides
- Unified Error Type: Single
Errorenum that covers all error cases across BRK crates - Convenient Result Type: Pre-configured
Result<T, E = Error>for consistent error handling - External Error Integration: Automatic conversions from common library errors
- Bitcoin-Specific Errors: Domain-specific error variants for blockchain data processing
Key Features
Centralized Error Management
- Single error type for the entire BRK ecosystem
- Consistent error handling patterns across all crates
- Reduced error type complexity in public APIs
External Library Integration
Automatic From implementations for errors from:
- I/O Operations:
std::io::Error - Bitcoin Core RPC:
bitcoincore_rpc::Error - Database Operations:
fjall::Error,vecdb::Error - Serialization:
serde_json::Error - Time Operations:
jiff::Error,SystemTimeError - HTTP Requests:
minreq::Error - Zero-Copy Operations:
zerocopyconversion errors
Bitcoin-Specific Error Variants
WrongAddressType- Invalid address type for operationUnindexableDate- Date before Bitcoin genesis (2009-01-03)WrongLength- Invalid data length for Bitcoin structuresQuickCacheError- Cache operation failures
Usage
Basic Error Handling
use ;
Working with External Libraries
use Result;
Bitcoin-Specific Validation
use ;
String Errors
// Static string errors (zero allocation)
Err
// Dynamic string errors
Err
Result Type
The crate provides a convenient Result type alias:
pub type Result<T, E = Error> = Result;
This allows for clean function signatures throughout BRK:
Error Display
All errors implement Display and std::error::Error, providing:
- Formatted error messages for debugging
- Error chain support for nested errors
- Integration with error handling libraries like
anyhow
Dependencies
vecdb- Vector database error typesbitcoincore-rpc- Bitcoin Core RPC client errorsfjall- Key-value store errorsjiff- Date/time operation errorsminreq- HTTP request errorsserde_json- JSON serialization errorszerocopy- Zero-copy conversion errors
This README was generated by Claude Code