codahale/bcrypt-ruby — pull request #51 by pda (2012-09-28 05:21:27+00:00)
Title: BCrypt::Errors::* descend from new BCrypt::Error.

The addition of a root BCrypt::Error class makes error handling far less verbose, and does not impact backwards compatibility. It also means code which rescues `BCrypt::Error` today will handle `BCrypt::Errors::InvalidMoonPhase` if it's added in future.

Before
------

```ruby
begin
# some BCrypt call
rescue BCrypt::Errors::InvalidSalt, BCrypt::Errors::InvalidHash,
BCrypt::Errors::InvalidCost, BCrypt::Errors::InvalidSecret
# handle error
end
```

After
-----

```ruby
begin
# ...
rescue BCrypt::Error
# ...
end
```

RSpec output:

Errors
BCrypt::Error
can be rescued as a StandardError
BCrypt::Errors::InvalidCost
can be rescued as a BCrypt::Error
BCrypt::Errors::InvalidHash
can be rescued as a BCrypt::Error
BCrypt::Errors::InvalidSalt
can be rescued as a BCrypt::Error
BCrypt::Errors::InvalidSecret
can be rescued as a BCrypt::Error