Skip to content

Conversation

@hakanensari
Copy link
Owner

Summary

Standardizes all error messages to use lowercase for consistency with Ruby conventions and improves type error messages to include attribute names for easier debugging.

Changes

Error Message Standardization:

  • "Cannot specify both type and block for :name""cannot specify both type and block for :name"
  • "Cannot specify X as type""cannot specify X as type for :attr"

Implementation:

  • Changed error messages in Builder and Types to lowercase
  • Added exception handling in Builder#coercions to catch and re-raise ArgumentError with attribute context
  • Updated tests to match new error format

Before/After

Before:

Structure.new { attribute(:value, Object.new) }
# ArgumentError: Cannot specify #<Object:0x...> as type

After:

Structure.new { attribute(:value, Object.new) }
# ArgumentError: cannot specify #<Object:0x...> as type for :value

Now developers immediately know which attribute has the invalid type!

Testing

  • All 139 tests pass
  • Updated test assertions to verify lowercase messages
  • Added assertion to verify attribute name is included in type errors

Closes #16

🤖 Generated with Claude Code

Makes all error messages lowercase and adds attribute context to type
errors for consistency with Ruby conventions and improved debugging.

Changes:
- Lowercase error messages: "cannot specify..." instead of "Cannot specify..."
- Add attribute name to type errors: "cannot specify X as type for :attr"
- Catch and re-raise ArgumentError in Builder#coercions to add context
- Update tests to match new error message format

Closes #16

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@hakanensari hakanensari merged commit eadbc01 into main Oct 16, 2025
15 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.

Standardize error message formatting

1 participant