Exceptions
All SDK exceptions inherit from EngramError and include a human-readable message explaining what to do.
Exception hierarchy
python
from engram.sdk import (EngramError, # base classMinerOfflineError, # miner is unreachableIngestError, # miner rejected the ingestQueryError, # query failed on the minerInvalidCIDError, # malformed CID returned)
| Exception | When raised | Common cause |
|---|---|---|
MinerOfflineError | Connection refused or timeout | Miner not running — start with python neurons/miner.py |
IngestError | Miner rejected the request | Rate limit, low stake, or text too long |
QueryError | Query failed on the miner | Store empty or miner error |
InvalidCIDError | Malformed CID returned | Miner-side bug — check miner logs |
Error handling
python
from engram.sdk import EngramClient, MinerOfflineError, IngestError, QueryErrorclient = EngramClient("http://127.0.0.1:8091")# Ingest with handlingtry:cid = client.ingest("Some important text")except MinerOfflineError as e:print(f"Miner is down: {e}")# → Can't reach the miner at http://127.0.0.1:8091# Start it with: python neurons/miner.pyexcept IngestError as e:print(f"Ingest rejected: {e}")# → Slow down — you've sent 12 requests in the last 60s.# Query with handlingtry:results = client.query("transformers")except MinerOfflineError:results = [] # fallback to cache or emptyexcept QueryError as e:print(f"Query failed: {e}")
engram docs · v0.1edit on github →