You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DataLoader methods → Result<Vec<Example>> (anyhow) + a custom DataLoadError for some paths
ResponseCache methods → anyhow throughout
Specific gaps:
LM errors aren't typed — network errors, rate limits (429), auth failures (401), model errors (400), and content policy (403) all come back as anyhow::Error. Callers can't match on error kind for retry logic. Need:
#[derive(thiserror::Error)]pubenumLmCallError{#[error("rate limited: retry after {retry_after_ms}ms")]RateLimited{retry_after_ms:u64},#[error("auth failed: {0}")]AuthFailed(String),#[error("model error: {status} {body}")]ModelError{status:u16,body:String},#[error("network error: {0}")]Network(#[from] reqwest::Error),#[error("content policy violation")]ContentPolicy,#[error("image responses not supported")]UnsupportedContent,}
Tool loop errors are stringly typed — "Max tool iterations reached" and "Tool 'x' not found" are anyhow::anyhow!() strings. Should be enum variants.
Cache errors — foyer errors bubble up as anyhow. Should wrap in a CacheError enum.
DataLoader — has DataLoadError for some paths but falls back to anyhow for others (HF download failures, parquet read errors). Should be consistent.
Optimizer errors — optimizers use anyhow::Result throughout. Long-running optimization that fails on trial 47/100 gives you a generic error with no context about which trial, which predictor, what the LM returned.
Activity
darinkishore commentedon Feb 11, 2026
should be retriable, nested, good error messages, cuz there are lots of sharp edges and that sucks for d users and d poor ais
darinkishore commentedon Feb 12, 2026
Codebase audit — current error handling state
Already using thiserror:
bamltype:BamlParseError,ConvertError,ParseError(well-structured, 3 enums)dspy-rs/core/errors.rs:PredictError,ParseError,LmError,ConversionError,JsonishError,ErrorClassWhere anyhow leaks through public API:
LM::call()→Result<LMResponse>(anyhow)LM::execute_tool_loop()→Result<ToolLoopResult>(anyhow)Cachetrait methods →Result<...>(anyhow)DataLoadermethods →Result<Vec<Example>>(anyhow) + a customDataLoadErrorfor some pathsResponseCachemethods → anyhow throughoutSpecific gaps:
LM errors aren't typed — network errors, rate limits (429), auth failures (401), model errors (400), and content policy (403) all come back as
anyhow::Error. Callers can't match on error kind for retry logic. Need:Tool loop errors are stringly typed —
"Max tool iterations reached"and"Tool 'x' not found"areanyhow::anyhow!()strings. Should be enum variants.Cache errors — foyer errors bubble up as anyhow. Should wrap in a
CacheErrorenum.DataLoader — has
DataLoadErrorfor some paths but falls back to anyhow for others (HF download failures, parquet read errors). Should be consistent.Optimizer errors — optimizers use
anyhow::Resultthroughout. Long-running optimization that fails on trial 47/100 gives you a generic error with no context about which trial, which predictor, what the LM returned.Priority order:
Related: #61 (tool loop), #69 (retry/backoff), #75 (Image todo panic)