Skip to content

Add a reason keyword arg to ParseError#initialize - #143

Open
sampersand wants to merge 1 commit into
ruby:masterfrom
sampersand:swesterman/2026-05-14/add-reason-kwarg-to-parseerror
Open

Add a reason keyword arg to ParseError#initialize#143
sampersand wants to merge 1 commit into
ruby:masterfrom
sampersand:swesterman/2026-05-14/add-reason-kwarg-to-parseerror

Conversation

@sampersand

@sampersandsampersand commented May 14, 2026

Copy link
Copy Markdown
Contributor

This adds a reason: keyword argument to ParseError#initialize for ergonomics and ease-of-use.

Before:

OptParse.acceptEncodingdo |arg|
Encoding.findargrescueArgumentErrorerr=OptionParser::InvalidArgument.newerr.reason="not a valid encoding"raiseerrend

Now:

OptParse.acceptEncodingdo |arg|
Encoding.findargrescueArgumentErrorraiseOptParse::InvalidArgument.new(reason: 'not a valid encoding')end

@sampersandsampersand changed the title add reason keyword arg to ParseError#initializeAdd a reason keyword arg to ParseError#initializeMay 14, 2026
@sampersand
sampersand marked this pull request as ready for review May 14, 2026 19:14
Sign up for freeto 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

@sampersand