Skip to content

Standardize bare Ruby exception messages to lowercase, unpunctuated - #2909

Merged
ericproulx merged 4 commits into
ruby-grape:masterfrom
dblock:standardize-error-messages
Sep 6, 2026
Merged

Standardize bare Ruby exception messages to lowercase, unpunctuated#2909
ericproulx merged 4 commits into
ruby-grape:masterfrom
dblock:standardize-error-messages

Conversation

@dblock

@dblock dblock commented Sep 5, 2026

Copy link
Copy Markdown
Member

Lowercases and removes trailing periods from the 7 ArgumentError messages in lib/ that deviated from the rest of the codebase's lowercase, unpunctuated style (dsl/entity.rb, dsl/inside_route.rb, dsl/validations.rb, validations/types/dry_type_coercer.rb), and documents the convention in CONTRIBUTING.md.

This matches Ruby's own core/stdlib exception style (e.g. TypeError: no implicit conversion from nil to integer), which reads naturally when printed after the exception class name and colon in a backtrace, and is consistent with how Grape::Exceptions::* messages are already written.

Updated the corresponding specs that asserted the old exact message text.

To help enforce this convention going forward, I created a new RuboCop plugin gem, rubocop-exception_messages, with ExceptionMessages/Casing and ExceptionMessages/Punctuation cops that flag/autocorrect exception messages violating this style. Added as a dev dependency here so CI catches any regressions.

Bumped to 0.2.0, which adds ExceptionMessages/QuoteStyle, enabled by default, wrapping interpolated values in backticks (e.g. "unknown type: `#{type}`") for consistency across error messages. Autocorrected the 16 affected messages across lib/ and spec/, and updated specs asserting exact message text accordingly.

@dblock
dblock force-pushed the standardize-error-messages branch from 63c925d to a736de5 Compare September 5, 2026 21:55
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Danger Report

No issues found.

View run

@dblock
dblock force-pushed the standardize-error-messages branch from a736de5 to f8e5a19 Compare September 5, 2026 21:56
@ericproulx

Copy link
Copy Markdown
Contributor

@dblock I'll make a release after this PR.

dblock and others added 3 commits September 6, 2026 12:55
Lowercase and remove trailing periods from ArgumentError messages in
dsl/entity.rb, dsl/inside_route.rb, dsl/validations.rb and
validations/types/dry_type_coercer.rb, matching the lowercase,
unpunctuated style already used everywhere else and consistent with
Ruby's own core/stdlib exceptions. Documents the convention in
CONTRIBUTING.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add the rubocop-exception_messages RuboCop plugin
(https://github.com/dblock/rubocop-exception_messages) to catch any
future regressions in exception message casing/punctuation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dblock
dblock force-pushed the standardize-error-messages branch from f49090f to 524de97 Compare September 6, 2026 16:55
… 0.2.0

Bump rubocop-exception_messages to 0.2.0, which adds the QuoteStyle
cop enforcing backtick-wrapped interpolated values in exception
messages by default. Autocorrect and fix affected spec assertions.
@dblock
dblock requested a review from ericproulx September 6, 2026 17:00
@dblock

dblock commented Sep 6, 2026

Copy link
Copy Markdown
Member Author

@ericproulx ready

@ericproulx
ericproulx merged commit 7b08d4b into ruby-grape:master Sep 6, 2026
36 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.

2 participants