Skip to main content

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:
  1. Retriability: Should the request failover to another provider?
  2. 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:
  1. Message-based patterns (highest priority)
  2. Code-based classification (fallback)

Message-Based Classification

Detects provider-specific error messages that don’t follow standard codes:
Priority Order:
  1. Rate limits (checked first)
  2. Auth errors
  3. Transient server errors (“please retry”)
  4. Result size violations (provider-specific capabilities)
  5. Other capability violations
Example:

Code-Based Classification

JSON-RPC 2.0 Standard Codes: EIP-1193 Provider Error Codes: HTTP Status Codes: Provider-Specific Codes:

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
Without exemption: Provider circuit breakers would permanently trip for valid architectural constraints. With exemption: Circuit breakers only track transient health issues (network errors, server crashes, timeouts).

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
Without exemption: Circuit breakers would trip during traffic spikes, removing healthy providers. With exemption: RateLimitState tiers down the provider temporarily, circuit breaker tracks actual failures.

Provider Capability Overrides

Providers can declare custom error classification rules in capabilities:
Evaluation Order:
  1. Provider-specific rules (top-to-bottom, first match wins)
  2. Global ErrorClassification (message patterns, then code ranges)
Implementation:

Common Error Patterns

Rate Limit Errors

DRPC Free Tier:
Category: :rate_limit Generic Rate Limit:
Category: :rate_limit

Capability Violations

Block Range Limit:
Category: :capability_violation Archival Data:
Category: :capability_violation Result Size Limit:
Category: :capability_violation (different providers have different limits)

Transient Server Errors

DRPC Retry Message:
Category: :server_error (message match: “please retry”) Generic Server Error:
Category: :server_error (message match: “temporarily unavailable”)

Invalid Client Requests

Invalid Parameters:
Category: :invalid_params Method Not Found:
Category: :method_not_found

Telemetry Integration

Circuit breaker telemetry includes error category:
Benefits:
  • Distinguish transient failures from capability constraints
  • Track rate limit incidents separately from server errors
  • Identify provider-specific error patterns

Best Practices

For Provider Configuration

  1. Add custom error_rules: Provider error codes/messages vary widely
  2. Test error scenarios: Verify classification matches expected behavior
  3. Document edge cases: Note provider-specific quirks in YAML comments

For Monitoring

  1. Alert on high breaker penalty errors: Server errors, network errors, timeouts
  2. Track capability violations separately: May indicate client usage pattern mismatch
  3. Monitor rate limit trends: May indicate need for tier upgrade or better load distribution

For Development

  1. Test both code and message: Classification logic has two paths
  2. Verify retriability: Failover behavior depends on correct classification
  3. Check breaker penalty: Ensure transient failures penalize, constraints don’t