Repository navigation
Closed
Labels
ready-for-agentScoped and ready for a contributor or agent to pick up
Milestone
Description
Parent: #137 · Epic: #126 · Blocked by: #133, and the decision elsewhere on where shared types and error classes live
Work on branch 137-build-detect-requests-and-read-typed-results-and-errors; commit the changes and close the ticket.
Problem
Every failure today is a ValueError, a provider exception, or a logged error that returns no spans (base.py:65-72, llm.py:109, llm.py:123, llm.py:424). Callers cannot handle failures by class or by stable code, and a degraded result has no place to say so.
Current behavior
lettucedetect/detectors/base.py:65_validate_min_confidenceraises a bareValueError.lettucedetect/detectors/llm.py:109and:123raiseValueErrorfor an unknown language and fornativewith judge-only options.- No error classes or warning model exist in the package.
Steps
- Implement a base class
LettuceDetectError(Exception)where the shared-types decision puts the error classes. It holds the stable snake_casecodeand the message, so a caller can catch every library error with oneexcept LettuceDetectErrorand read.code. - Implement three subclasses of
LettuceDetectError:InvalidInputError(an argument of a call; also hasparam),ConfigurationError(a constructor argument, a setting or a missing package;paramoptional),UpstreamError(a failed or missing reply from a service). Whether they also subclassValueErrorfollows the decision. If they do,LettuceDetectErrorstays the common base. - Implement the result warning model with a stable
code; other fields follow the decision. - An error built from a request never puts customer text in its message (refer to items by position). Chain foreign errors with
raise ... from; the base class keeps__cause__intact. - Export
LettuceDetectErrorand the three subclasses fromlettucedetect.detectors.
Acceptance criteria
-
LettuceDetectErrorexists with acode;InvalidInputError,ConfigurationErrorandUpstreamErrorare subclasses of it, soexcept LettuceDetectErrorcatches all three. - Every error has
code,InvalidInputErrorhasparam; a test checkscodeandparamare readable as attributes and that__cause__is kept when chained. - A test builds an error from a request containing a known answer and asserts the message does not contain it.
- The warning model has a
code; importable fromlettucedetect.detectors. - No detector changes; existing tests pass; follows CONTRIBUTING "Errors and logging".
Start here
uv run --extra dev pytest tests -q -x
Metadata
Metadata
Assignees
Labels
ready-for-agentScoped and ready for a contributor or agent to pick up
Activity
chore: add LettuceDetectError, its three subclasses and the result wa…