Something went wrong. Try again.
Original-language reader for Kant, Aristotle & more: select any passage to gloss, translate, or hear it read aloud, with exact citations.
Something went wrong. Try again.
12345678910111213141516171819202122import { ConvexError } from "convex/values"
/** * Friendly message for a structured guard rejection from the paid actions * (`convex/limits.ts` — `span_too_long` on an over-long selection, * `rate_limited` when the reader's gloss/TTS budget is spent), or `null` for * any other error. Like `isUnauthenticatedError`, detection is structural on * `ConvexError.data.kind`, never on message strings; the server writes these * messages for the reader, so they're shown verbatim (toast + inline). */export function limitErrorMessage(e: unknown): string | null { if (!(e instanceof ConvexError)) return null const data = e.data as { kind?: unknown; message?: unknown } if ( (data.kind === "rate_limited" || data.kind === "span_too_long") && typeof data.message === "string" ) { return data.message } return null}