Skip to content

jgorset/reraises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reraises

Build Status Code Climate

It's a good idea to reraise exceptions from third-party libraries as your own so you're not leaking implementation details all over your codebase. For example, I would rather deal with my own Facebook::Page::Inaccessible exception than FbGraph::NotFound outside of my Facebook adapter.

If your adapter has lots of places that could leak exceptions, however, reraising them everywhere gets old really fast. That's where reraises comes in.

Usage

class Adapter
  extend Reraises

  reraise FbGraph::NotFound, as: Facebook::Page::Inaccessible, in: "query"

  def query
    raise FbGraph::NotFound, "This will be reraised as Facebook::Page::Inaccessible"
  end
end

Installation

Add this line to your application's Gemfile:

gem 'reraises'

And then execute:

$ bundle

Or install it yourself as:

$ gem install reraises

I love you

Johannes Gorset made this. You should tweet me if you can't get it to work. In fact, you should tweet me anyway.

About

Reraise an exception as another

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages