A Rails engine for arbitrary message creation and delivery.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install blorg
class PagesController def show @page = Page.find(params[:id]) rescue ActiveRecord::RecordNotFound => exception .( channels: [:database, :logger], reporters: [exception, current_user, request] ) end end
Given the above Rails-like code When a user attempts to find a page that does not exist Then an exception is raised And the Harbinger.call code will:
- Build a message based on the three reporters:
- The raised exception
- The current user
- The request
- Deliver that message to the two channels:
For further details I recommend delving into the end to end exception handling spec
Extending Contexts and Channels
Harbinger is built to allow for easy creation of new Contexts and Channels.