Reference
Errors
Mostly Right fails loudly when data is unavailable, temporally unsafe, or incompatible with a contract. Catch the four stable root exceptions for application control flow, then reach for a specialized subtype when you need a narrower recovery path.
Stable root exceptions
Section titled “Stable root exceptions”import mostlyright as mr
try: table = mr.weather.training_table("KNYC", from_date, to_date)except mr.LeakageError: # A row was not knowable by the decision cutoff. ...except mr.ContractError: # An input or output frame broke a documented contract. ...except mr.NoDataError: # No usable rows were available. ...except mr.MostlyrightError: # Any other structured SDK error. ...MostlyrightError, LeakageError, ContractError, and NoDataError are available directly from mostlyright. Structured errors expose error_code, source, request_id, and a JSON-safe to_dict() payload when those fields apply.
TypeScript mirrors the same teaching families:
import { ContractError, LeakageError, MostlyrightError, NoDataError,} from "mostlyright";TypeScript errors expose errorCode, source, requestId, and toDict().
Common specialized errors
Section titled “Common specialized errors”Import specialized Python exceptions from mostlyright.core.exceptions unless a domain documents a closer import path.
| Family | Common members | Raised when |
|---|---|---|
| Availability | DataAvailabilityError, SourceUnavailableError, PayloadTooLargeError | A source, date window, cache entry, or payload cannot be served |
| Live data | LiveStreamError, NoLiveDataError, NoCWOPDataError | A live source has no fresh usable report |
| Temporal safety | LeakageError, OpenMeteoSeamlessLeakageError, TemporalDriftError | Data crosses a decision cutoff or two timelines disagree |
| Contracts | ContractError, SchemaValidationError, LabelAlignmentError, IssuedAtMissingError, UnitsContractError | A frame, label, timestamp, or unit breaks its contract |
| Provenance | SourceMismatchError | Research and live source identities do not match |
| Forecasts | NWPError, NWPModelNotAvailableError, NWPModelRetiredError, GRIBIntegrityError, HistoricalDepthError, NoLiveForNWPError, StormNotFoundError | A forecast model or requested depth is unavailable or invalid |
| Satellite | SatelliteError, GOESS3Error, GOESDataCorruptError, ProductNotRegisteredError, StationOutOfGridError | A satellite product, object, or station projection fails |
| Economy and finance | IndicatorNotYetReleasedError, EarningsError, EarningsFactCorruptError, CaptureNotAvailableError, KalshiCountRuleViolationError | A release or earnings artifact is not yet available or fails validation |
Missing live data
Section titled “Missing live data”weather.live.latest() raises NoLiveDataError instead of returning an old report as if it were current.
import asynciofrom mostlyright import weatherfrom mostlyright.core.exceptions import NoLiveDataError
try: report = asyncio.run(weather.live.latest("KNYC"))except NoLiveDataError as error: print(error.source) print(error.to_dict())This is a normal operational branch. Retry according to your policy, switch to another active station, or stop the live decision. Do not silently substitute archived or stale data.
Data availability reasons
Section titled “Data availability reasons”DataAvailabilityError adds a stable reason value and an operator-facing hint. The reason enum is shared across Python and TypeScript:
model_unavailableout_of_windowcache_misssource_404source_5xxrate_limited
Branch on reason, not message text.
HTTP errors
Section titled “HTTP errors”TherminalError was renamed to HttpError in 2.0. The HTTP family also includes NotFoundError, RateLimitError, ValidationError, AuthenticationError, ForbiddenError, and ServerError.
Market-specific errors
Section titled “Market-specific errors”Polymarket settlement can raise PolymarketEventError, PolymarketSettlementError, PolymarketStrikeError, or TooEarlyToSettleError.
KalshiTickerError is intentionally a ValueError, not a MostlyrightError, because a malformed ticker is caller input:
from mostlyright.markets.kalshi import KalshiTickerError, parse_ticker
try: parsed = parse_ticker(user_supplied_ticker)except KalshiTickerError: ...See also
Section titled “See also”- Temporal safety: decision cutoffs and leakage checks
- API reference: stable and experimental entry points
- SDK migration: 2.0 renames and removals