Overview
NanoARB uses Rust’s type-safe error handling with theResult type. All errors implement the thiserror::Error trait for consistent error messages and conversions.
Error Type
The coreError enum defines all possible error conditions.
Definition
Result Type
A type alias for convenience.Error Variants
InvalidPrice
Returned when a price value is invalid.- Negative prices where not allowed
- Price exceeds maximum allowed value
- Invalid price format in parsing
InvalidQuantity
Returned when a quantity value is invalid.- Zero quantity for orders
- Quantity exceeds maximum
- Invalid quantity format
InvalidOrderId
Returned when an order ID is invalid.InvalidTimestamp
Returned when a timestamp value is invalid.- Timestamps in the future (when not allowed)
- Timestamps before Unix epoch (when not allowed)
- Invalid timestamp format
InvalidInstrument
Returned when an instrument identifier is invalid.- Unknown instrument symbol
- Instrument not configured
- Invalid instrument ID
OrderNotFound
Returned when an order cannot be found.- Attempting to cancel non-existent order
- Querying order that was never created
- Order ID typo
InsufficientLiquidity
Returned when there’s not enough liquidity to fill an order.- Market order larger than available liquidity
- Thin order book
- Attempting to fill at specific price level with insufficient depth
RiskLimitExceeded
Returned when a risk limit is breached.- Position limit exceeded
- Order size too large
- Drawdown limit breached
- Daily loss limit hit
ParseError
Returned when parsing fails.- Invalid data format
- Malformed configuration
- Corrupt market data
ConfigError
Returned when configuration is invalid.- Missing configuration fields
- Invalid configuration values
- Conflicting configuration options
IoError
Returned when I/O operations fail.- File not found
- Permission denied
- Disk full
- Network connection lost
SerializationError
Returned when serialization/deserialization fails.- Invalid data format
- Version mismatch
- Corrupt data
ModelError
Returned when ML model inference fails.- Invalid input shape
- Model not loaded
- Inference timeout
- GPU out of memory
Internal
Returned for unexpected internal errors.- Invariant violations
- Unexpected state
- Programming errors
Error Handling Patterns
Basic Error Handling
Using the ? Operator
The? operator propagates errors up the call stack.