0.0
No commit activity in last 3 years
No release in over 3 years
DealWithIt is an exception handler for Ruby applications.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 10.0
~> 3.0
 Project Readme

DealWithIt

DealWithIt

Maintainability Test Coverage CircleCI

Installation

Add this line to your application's Gemfile:

gem 'deal_with_it'

And then execute:

$ bundle

Usage

Include the handler base on your ApplicationController or in any class you wish to handle.

class ApplicationController < ActionController::Base
  include DealWithIt
end

Create your custom handler anywhere in the app.

# app/handlers/record_not_found_handler.rb
class RecordNotFoundHandler < DealWithIt::Handler
  deal ActiveRecord::RecordNotFound, with: ->(error) do
    render json: { message: 'Oopsie, we didn\'t found that stuff' }, status: :not_found
  end
end

Note that render is a method that comes from the ActionController itself, it could be any method from the class that included the DealWithIt module.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/leonardofalk/deal_with_it.

License

The gem is available as open source under the terms of the MIT License.