Skip to content

(docs): add the error handling and logging convention to CONTRIBUTING.md (#133) - #185

Merged
hslev merged 1 commit into
stateless_corefrom
132-read-the-errors-and-logging-convention-in-contributingmd
Nov 6, 2026
Merged

hslev merged 1 commit into
stateless_corefrom
132-read-the-errors-and-logging-convention-in-contributingmd

Conversation

@hslev

@hslev hslev commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an "Errors and logging" section to CONTRIBUTING.md, adapted from VerbatimRAG's contributor guide, so later tasks and reviews apply the same rules.

  • Scope: library code in lettucedetect/ follows the rules. The CLI, lettucedetect_api/, scripts, demo, training and evaluation are applications and may print.
  • Errors:
    • A call returns a correct result or raises, and a degraded result says so in its warnings.
    • InvalidInputError (with param), ConfigurationError and UpstreamError.
    • A stable snake_case code on every error and warning.
    • Messages carry no secrets or customer text and refer to items by position.
    • Log or raise, never both. No bare except Exception outside application boundaries.
    • A fallback catches only UpstreamError and adds a warning.
    • warnings.warn is for deprecations only, using LettuceDetectDeprecationWarning.
  • Logging:
    • One module logger per module. No printing, handlers or basicConfig in library code.
    • %-style arguments.
    • The events model_loaded, fallback_used and item_failed, plus a level table.
    • Customer text only on lettucedetect.content, at DEBUG.
  • Related edits: the print() code-style line now points to the new section, and a new step 3 in "Making changes" links to it (later steps renumbered).

No production code or tests changed.

Related issue

Closes #133 (parent: #132, epic: #126).

This PR targets stateless_core, so GitHub won't close the issue on merge. Close it by hand.

Type of change

  • Bug fix
  • Feature
  • Documentation
  • Tests
  • Refactor or maintenance

Testing

Documentation-only change. No code or tests were touched, so I did not run the lint or test commands.

  • ruff format --check lettucedetect/ lettucedetect_api/ tests/
  • ruff check lettucedetect/ lettucedetect_api/ tests/ --extend-exclude lettucedetect/integrations/
  • python -m pytest

Checklist

  • I kept the PR focused on one change.
  • I added or updated tests/docs when needed.
  • I checked that no secrets, API keys, or credentials are included.

Rights & sign-off (required)

  • I certify that I have the right to submit this code and that it may be
    distributed under the repository's MIT license
    (see CONTRIBUTING).

@hslev
hslev merged commit 6cae1ed into stateless_core Nov 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant