HttpErrors
This is helpful gem for easily managing, raising and catching basic HTTP errors.
Installation
Add this line to your application's Gemfile:
gem 'http_errors'
And then execute:
$ bundle
Or install it yourself as:
$ gem install http_errors
Usage
You can use in your controller:
rescue_from HTTPError do |exception|
head exception.class.head
end
and use it anywhere as:
raise HTTPErrors::Unauthorized unless …
Available errors ErrorName(error_code, error_status)
:
Unauthorized (401, :unauthorized)
Forbidden (403, :forbidden)
NotFound (404, :not_found)
NotAcceptable (406, :not_acceptable)
Contributing
- Fork it (https://github.com/KamilLelonek/http_errors/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request