Skip to content

Pass the message through in Channel::ValidationError - #1124

Open
costajohnt wants to merge 1 commit into
ruby-concurrency:masterfrom
costajohnt:fix-channel-validation-error-message
Open

costajohnt wants to merge 1 commit into
ruby-concurrency:masterfrom
costajohnt:fix-channel-validation-error-message

Conversation

@costajohnt

Copy link
Copy Markdown

Concurrent::Channel::ValidationError#initialize sets a default message but never calls super, so the message is always the class name:

Concurrent::Channel::ValidationError.new.message          # => "Concurrent::Channel::ValidationError"
Concurrent::Channel::ValidationError.new("boom").message  # => "Concurrent::Channel::ValidationError"

As a result Channel#put!(nil) and Channel#offer!(nil) lose their "nil is not a valid value" message, and a failed validator gives the class name instead of "invalid value".

Fix: call super(message), the same as Concurrent::Agent::ValidationError already does.

Test: the put! specs for "rejects when the validator returns false" and "rejects nil" in spec/concurrent/channel_spec.rb now check the message as well as the class. Both fail on master and pass with this change.

Found with rbcop, RuboCop reimplemented in Rust.

initialize set a default message but never called super, so the message was
always the class name.

This branch has not been deployed

No deployments
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