Implement standardized error message templates #296

Closed
opened 2026-03-16 01:59:23 +00:00 by freemo · 0 comments
Owner

Metadata

Key Value
Branch feature/m1-error-templates
Commit Message feat: implement standardized error message templates
Parent Epic #291 — Input Validation Framework

Background and Context

Currently, error messages across command handlers are inconsistent — some are terse, some verbose, some use different terminology for the same concept. Standardized error message templates ensure players receive clear, consistent, and helpful feedback when validation fails. These templates are used by the validation pipeline and all validators.

Expected Behavior

A ValidationMessages module provides 15 templated error messages that accept interpolation parameters. Messages are player-friendly (no technical jargon), consistently formatted, and helpful (suggesting corrections where possible).

The 15 templates:

  1. unknown_command — "I don't understand '%{input}'."
  2. missing_required_param — "The %{param_name} is required."
  3. invalid_type — "'%{value}' is not a valid %{expected_type}."
  4. object_not_found — "You don't see '%{name}' here."
  5. player_not_found — "No player named '%{name}' is currently online."
  6. ambiguous_object — "Which %{name} do you mean? %{options}"
  7. direction_invalid — "'%{value}' is not a valid direction."
  8. permission_denied — "You cannot do that."
  9. too_many_params — "Too many words. Usage: %{usage}"
  10. not_enough_params — "Not enough detail. Usage: %{usage}"
  11. invalid_enum_value — "'%{value}' must be one of: %{valid_values}."
  12. target_not_in_scope — "You can't reach %{name} from here."
  13. number_out_of_range — "%{value} is out of range (%{min}–%{max})."
  14. action_not_possible — "You can't %{action} right now."
  15. cooldown_active — "You must wait %{seconds} seconds before doing that again."

Acceptance Criteria

  • ValidationMessages module is defined with all 15 template methods.
  • Each template accepts keyword arguments for interpolation.
  • Messages contain no technical jargon (no class names, no stack traces).
  • Messages are consistently formatted (sentence case, proper punctuation).
  • Templates are used by the validation pipeline and all validators.
  • Templates are easily overridable for customization or localization.

Subtasks

Code

  • Create ValidationMessages module.
  • Define all 15 message template methods with keyword interpolation.
  • Add message override mechanism (e.g., configuration hash or subclass).
  • Integrate templates into ValidationPipeline error generation.
  • Integrate templates into ObjectFinder, DirectionValidator, and PlayerOnlineValidator.
  • Add usage string generation from ParamDefinition for usage-related messages.

Quality

  • Docs: Update YARD comments on affected classes and methods. Update relevant Docusaurus documentation pages if applicable.
  • Tests (Cucumber): Add tests/unit/error_templates.feature covering all 15 message templates with interpolation, override mechanism, integration with pipeline errors, usage string generation.
  • Tests (Cucumber Integration): Add integration feature in tests/integration/ for standardized error messages appearing in player output during validation failures.
  • Tests (Profiling): Run bundle exec rake unit_profile and verify no performance regressions.
  • Quality: Verify coverage >=97% via bundle exec rake unit. If coverage is <97% then review the current unit test coverage report at build/tests/unit/coverage/ and use it to write new Cucumber based unit tests to improve coverage. Specifically, write Cucumber/Gherkin style unit tests that are descriptively named and specifically improve coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun bundle exec rake unit to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%.
  • Quality: Run bundle exec rake (default task: unit tests with coverage) and bundle exec rake integration, fix any errors if needed ensuring both pass across entire code base, do not ignore any failure even if it seems unrelated to this commit, fix it.

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
## Metadata | Key | Value | |-----|-------| | **Branch** | `feature/m1-error-templates` | | **Commit Message** | `feat: implement standardized error message templates` | | **Parent Epic** | #291 — Input Validation Framework | ## Background and Context Currently, error messages across command handlers are inconsistent — some are terse, some verbose, some use different terminology for the same concept. Standardized error message templates ensure players receive clear, consistent, and helpful feedback when validation fails. These templates are used by the validation pipeline and all validators. ## Expected Behavior A `ValidationMessages` module provides 15 templated error messages that accept interpolation parameters. Messages are player-friendly (no technical jargon), consistently formatted, and helpful (suggesting corrections where possible). The 15 templates: 1. `unknown_command` — "I don't understand '%{input}'." 2. `missing_required_param` — "The %{param_name} is required." 3. `invalid_type` — "'%{value}' is not a valid %{expected_type}." 4. `object_not_found` — "You don't see '%{name}' here." 5. `player_not_found` — "No player named '%{name}' is currently online." 6. `ambiguous_object` — "Which %{name} do you mean? %{options}" 7. `direction_invalid` — "'%{value}' is not a valid direction." 8. `permission_denied` — "You cannot do that." 9. `too_many_params` — "Too many words. Usage: %{usage}" 10. `not_enough_params` — "Not enough detail. Usage: %{usage}" 11. `invalid_enum_value` — "'%{value}' must be one of: %{valid_values}." 12. `target_not_in_scope` — "You can't reach %{name} from here." 13. `number_out_of_range` — "%{value} is out of range (%{min}–%{max})." 14. `action_not_possible` — "You can't %{action} right now." 15. `cooldown_active` — "You must wait %{seconds} seconds before doing that again." ## Acceptance Criteria - [ ] `ValidationMessages` module is defined with all 15 template methods. - [ ] Each template accepts keyword arguments for interpolation. - [ ] Messages contain no technical jargon (no class names, no stack traces). - [ ] Messages are consistently formatted (sentence case, proper punctuation). - [ ] Templates are used by the validation pipeline and all validators. - [ ] Templates are easily overridable for customization or localization. ## Subtasks ### Code - [ ] Create `ValidationMessages` module. - [ ] Define all 15 message template methods with keyword interpolation. - [ ] Add message override mechanism (e.g., configuration hash or subclass). - [ ] Integrate templates into `ValidationPipeline` error generation. - [ ] Integrate templates into `ObjectFinder`, `DirectionValidator`, and `PlayerOnlineValidator`. - [ ] Add usage string generation from `ParamDefinition` for usage-related messages. ### Quality - [ ] Docs: Update YARD comments on affected classes and methods. Update relevant Docusaurus documentation pages if applicable. - [ ] Tests (Cucumber): Add `tests/unit/error_templates.feature` covering all 15 message templates with interpolation, override mechanism, integration with pipeline errors, usage string generation. - [ ] Tests (Cucumber Integration): Add integration feature in `tests/integration/` for standardized error messages appearing in player output during validation failures. - [ ] Tests (Profiling): Run `bundle exec rake unit_profile` and verify no performance regressions. - [ ] Quality: Verify coverage >=97% via `bundle exec rake unit`. If coverage is <97% then review the current unit test coverage report at `build/tests/unit/coverage/` and use it to write new Cucumber based unit tests to improve coverage. Specifically, write Cucumber/Gherkin style unit tests that are descriptively named and specifically improve coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun `bundle exec rake unit` to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%. - [ ] Quality: Run `bundle exec rake` (default task: unit tests with coverage) and `bundle exec rake integration`, fix any errors if needed ensuring both pass across **entire** code base, do not ignore any failure even if it seems unrelated to this commit, fix it. ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done.
freemo added this to the v1.0.0 milestone 2026-03-16 01:59:23 +00:00
freemo self-assigned this 2026-03-16 01:59:23 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference: aethyr/Aethyr#296
No description provided.