8000 Hardening 2/4: every error code explained; clear messages for unusable formulas by rafatahmed · Pull Request #119 · rafatahmed/Flahax · GitHub
[go: up one dir, main page]

Skip to content

Hardening 2/4: every error code explained; clear messages for unusable formulas - #119

Merged
rafatahmed merged 1 commit into
mainfrom
fix/error-catalogue
Oct 23, 2026
Merged

rafatahmed merged 1 commit into
mainfrom
fix/error-catalogue

Conversation

@rafatahmed
Copy link
Copy Markdown
Owner

Second of four hardening PRs (entry points, errors, PEP 8 and file headers, docstrings).

Error code reference

The shipped user guide (USER_GUIDE.md, section 8) now explains all 91 DeliveryError codes: 68 were undocumented. Grouped by what you were doing (input values and files; water analysis; products and materials; recipe, limits and pH; chemistry model; stocks, tanks and injection; delivery plans, EC and reference data), each with its meaning and what to do, written from the messages the code actually raises. tests/test_error_catalogue.py fails if any raised code is missing (it found one the manual sweep missed, invalid_ions).

Formula messages

A material with an unusable formula said 'give its formula, its ions, or its analysis' even when a formula was given. It now says why:

  • 'Ca(NO3' -> cannot be read: check the brackets and the element symbols;
  • 'C6H12O6' -> does not split into the fertilizer ions FlahaX knows;
  • 'Ch micro' -> is a name, not a chemical formula;
  • fractional atoms, or more than one way to split, each named.

Exception audit

Users meet only InputError and DeliveryError. The remaining TypeErrors are argument-type checks (standard Python), the AssertionErrors belong to the reference-fixture comparison helper, and the internal ValueErrors (formula parser, least squares, calibration timestamps, mix entry) are caught and re-raised as FlahaX errors. No change needed.

Behaviour unchanged

The 97-result baseline (26 recipes, 52 complete batches, 19 farmer sessions) is identical. 537 tests with live PHREEQC required; tools/verify_distribution.py PASS; no 3.12-only f-strings; LF.

@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 Flahax | 🛠️ Build #35352425 | 📁 Comparing 87e3ee6 against latest (fccba90)

  🔍 Preview build  

2 files changed
± changelog.html
± guide/manual.html

@rafatahmed
rafatahmed merged commit ff675b2 into main Oct 23, 2026
7 checks passed
@rafatahmed
rafatahmed deleted the fix/error-catalogue branch October 23, 2026 11:13
@rafatahmed rafatahmed self-assigned this Oct 23, 2026
rafatahmed added a commit that referenced this pull request Nov 7, 2026
Hardening 2/4: every error code explained; clear messages for unusable formulas
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

0