Skip to main content

Error Handling

All SDK methods return polynode::Result<T>, which wraps polynode::Error:
use polynode::{PolyNodeClient, Error};

# async fn example() -> polynode::Result<()> {
let client = PolyNodeClient::new("pn_live_test_session_tracking_51eca107e9b347b589f5b0a04f98eb1d")?;

match client.market("invalid-token-id").await {
    Ok(market) => println!("{:?}", market),
    Err(Error::NotFound(msg)) => println!("not found: {}", msg),
    Err(Error::Auth(msg)) => println!("auth failed: {}", msg),
    Err(Error::RateLimited(msg)) => println!("rate limited: {}", msg),
    Err(Error::Api { status, message }) => println!("API error {}: {}", status, message),
    Err(Error::Http(e)) => println!("network error: {}", e),
    Err(Error::Disconnected) => println!("WebSocket disconnected"),
    Err(e) => println!("other: {}", e),
}
# Ok(())
# }

Error Variants

VariantWhen it occurs
HttpNetwork-level request failure
WebSocketWebSocket connection or protocol error
JsonResponse deserialization failure
Api { status, message }Server returned a non-success status
Auth401 or 403 from the API
RateLimited429 from the API
NotFound404 from the API
DisconnectedWebSocket connection lost
Decompressionzlib decompression failure
ConnectionClosedServer closed the WebSocket
UrlURL parse error
TradingTrading-specific error (feature: trading)
SigningEIP-712 signing failure (feature: trading)
SqliteLocal database error (feature: cache or trading)
IoFile I/O error (feature: cache or trading)
CacheCache-specific error (feature: cache)