Skip to content

The wrong types of exceptions are being raised #4

@ajvondrak

Description

@ajvondrak

In places like

raise ArgumentError, "NOSCRIPT No matching script. Please use EVAL."
a generic ArgumentError is being raised. However, the actual redis client will raise things like Redis::CommandError (for the NOSCRIPT error at least). You'll notice that the mock_redis gem takes care to raise the same sorts of errors: https://github.com/brigade/mock_redis/search?q=commanderror&unscoped_q=commanderror

As is, I now have to write my code like

begin
  $redis.evalsha(...)
rescue Redis::CommandError, ArgumentError => error # notice the two types of errors here
  raise unless error.message.start_with?('NOSCRIPT')
  $redis.eval(...)
end

Using only one class or the other, either my test suite will break or my real-world code will. So I think it's prudent to go through each raise and determine whether the right type of error is being used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions