Overview
Lasso’s error classification system provides semantic categorization of errors from providers, transports, and JSON-RPC responses. The classification determines both retriability (failover behavior) and circuit breaker penalty semantics. Location:Lasso.Core.Support.ErrorClassification
Error Categories
Each category determines:- Retriability: Should the request failover to another provider?
- Circuit Breaker Penalty: Should this error count against the provider’s failure threshold?
Retriable Categories
:rate_limit
- Provider rate limiting or quota exceeded
- Temporary backpressure (will recover)
- Retriable: Yes (try different provider)
- Breaker Penalty: No (not a failure, just temporary constraint)
- Examples: “rate limit exceeded”, “too many requests”, “quota exceeded”
:network_error
- Network/connectivity issues
- Transient failures (TCP errors, timeouts)
- Retriable: Yes
- Breaker Penalty: Yes
- Examples: Connection refused, DNS failure, socket timeout
:server_error
- Provider-side server errors (5xx, provider crashes)
- Retriable: Yes
- Breaker Penalty: Yes
- Examples: “please retry”, “temporary internal error”, HTTP 500-599
:capability_violation
- Provider lacks capability for this request
- Retriable: Yes (try provider with different capabilities)
- Breaker Penalty: No (permanent constraint, not transient failure)
- Examples: “block range too large”, “archive node required”, “tracing not enabled”
:method_not_found
- Method not supported by this provider
- Retriable: Yes (try provider that supports the method)
- Breaker Penalty: Yes
- Examples: JSON-RPC -32601, “method unavailable”
:internal_error
- Provider internal error (JSON-RPC -32603)
- Retriable: Yes
- Breaker Penalty: Yes
:auth_error
- Authentication/authorization failure
- Retriable: Yes (credentials may work on different provider)
- Breaker Penalty: Yes
- Examples: “unauthorized”, “api key”, “forbidden”
:chain_error
- Chain-level error (e.g., unsupported chain)
- Retriable: Yes
- Breaker Penalty: Yes
- Examples: EIP-1193 4900, “unsupported chain”
Non-Retriable Categories
:invalid_request
- Malformed JSON-RPC request
- Retriable: No (client error, won’t succeed elsewhere)
- Breaker Penalty: No (not provider’s fault)
- Examples: JSON-RPC -32600
:invalid_params
- Invalid method parameters
- Retriable: No
- Breaker Penalty: No
- Examples: JSON-RPC -32602, “invalid address format”
:parse_error
- JSON parsing failure
- Retriable: No
- Breaker Penalty: No
- Examples: JSON-RPC -32700
:user_error
- User rejected transaction (EIP-1193)
- Retriable: No
- Breaker Penalty: No
- Examples: EIP-1193 4001 (user rejected)
:client_error
- Generic client error (4xx)
- Retriable: No
- Breaker Penalty: No
- Examples: HTTP 400, 403, 404
Special Categories
:timeout
- Request timeout
- Retriable: Yes
- Breaker Penalty: Yes
:provider_error
- Infrastructure-level provider unavailability (no channels, pool errors)
- Retriable: Yes
- Breaker Penalty: Yes
:unknown_error
- Unclassified error (fallback category)
- Retriable: No (conservative default)
- Breaker Penalty: Yes
Classification Strategy
Two-stage classification:- Message-based patterns (highest priority)
- Code-based classification (fallback)
Message-Based Classification
Detects provider-specific error messages that don’t follow standard codes:- Rate limits (checked first)
- Auth errors
- Transient server errors (“please retry”)
- Result size violations (provider-specific capabilities)
- Other capability violations
Code-Based Classification
JSON-RPC 2.0 Standard Codes:| Code | Category | Retriable? |
|---|---|---|
| -32700 | :parse_error | No |
| -32600 | :invalid_request | No |
| -32601 | :method_not_found | Yes |
| -32602 | :invalid_params | No |
| -32603 | :internal_error | Yes |
| -32000 to -32099 | :server_error | Yes |
| Code | Category | Retriable? |
|---|---|---|
| 4001 | :user_error | No |
| 4100 | :auth_error | Yes |
| 4200 | :method_error | Yes |
| 4900 | :chain_error | Yes |
| 4901 | :network_error | Yes |
| Code Range | Category | Retriable? |
|---|---|---|
| 429 | :rate_limit | Yes |
| 500-599 | :server_error | Yes |
| 400-499 | :client_error | No |
API Reference
categorize/2
Categorizes an error into a semantic category.retriable?/2
Determines if an error should trigger failover to another provider.retriable_for_category?/1
Determines if a category should trigger failover.breaker_penalty?/1
Determines if an error should count against circuit breaker failure threshold.Integration with Circuit Breakers
Classification Flow
Why No Penalty for Capability Violations?
Capability violations represent permanent constraints, not transient failures:- A provider without archival data will never have archival data
- A free tier provider will always have block range limits
- Tracing unavailability is a configuration decision, not a health issue
Why No Penalty for Rate Limits?
Rate limits are temporary backpressure with known recovery:- Rate limits reset on a predictable schedule (per second, per hour)
- RateLimitState tiering handles backpressure without circuit breakers
- Provider is healthy, just temporarily at capacity
Provider Capability Overrides
Providers can declare custom error classification rules in capabilities:- Provider-specific rules (top-to-bottom, first match wins)
- Global ErrorClassification (message patterns, then code ranges)
Common Error Patterns
Rate Limit Errors
DRPC Free Tier::rate_limit
Generic Rate Limit:
:rate_limit
Capability Violations
Block Range Limit::capability_violation
Archival Data:
:capability_violation
Result Size Limit:
:capability_violation (different providers have different limits)
Transient Server Errors
DRPC Retry Message::server_error (message match: “please retry”)
Generic Server Error:
:server_error (message match: “temporarily unavailable”)
Invalid Client Requests
Invalid Parameters::invalid_params
Method Not Found:
:method_not_found
Telemetry Integration
Circuit breaker telemetry includes error category:- Distinguish transient failures from capability constraints
- Track rate limit incidents separately from server errors
- Identify provider-specific error patterns
Best Practices
For Provider Configuration
- Add custom error_rules: Provider error codes/messages vary widely
- Test error scenarios: Verify classification matches expected behavior
- Document edge cases: Note provider-specific quirks in YAML comments
For Monitoring
- Alert on high breaker penalty errors: Server errors, network errors, timeouts
- Track capability violations separately: May indicate client usage pattern mismatch
- Monitor rate limit trends: May indicate need for tier upgrade or better load distribution
For Development
- Test both code and message: Classification logic has two paths
- Verify retriability: Failover behavior depends on correct classification
- Check breaker penalty: Ensure transient failures penalize, constraints don’t
Related Documentation
- WebSocket Subscriptions - Failover triggers based on error classification
- Benchmarking - Error categories tracked in performance metrics
- Block Sync - Health probe error handling