[ANN] Exceptional 1.0 - A new style of handling exceptions

Exceptional is a plugin for Ruby on Rails that brings exception
handling into
the world of RoR filters. Through two declarative statements that are
similar in
style to filter declarations in your controllers you get easy and
powerful
exception handling in your application.

An example usage:

class RubberDuckiesController < ApplicationController
handles :unhandled, :with => :unhandled_error
handles AccessDeniedError, :with => :access_denied, :except =>
[:list, :show]

  raises  InvalidRequest, :if => {:method => [:destroy]}, :only =>

[:list, :new]

  def create
    ...
    raise AccessDeniedError
    ...
  end

  private
  def access_denied
    render system_path('access_denied')
  end

  def unhandled_error
    redirect_to new_error_report_path
  end
end

See the README for full info on all of the features:
http://hg.nullstyle.com/exceptional/file/tip/README

Please note that this is only compatible with rails 1.2RC and newer,
and the tests are written using RSpec.

To Install:
script/plugin install http://hg.nullstyle.com/raw/exceptional

For More Info:
http://nullstyle.com/home/exceptional

To Browse The Source:
http://hg.nullstyle.com/exceptional

Agile Web D. Plugin Page:
http://www.agilewebdevelopment.com/plugins/exceptional

Thanks for your time,
Scott Fleckenstein

On Nov 27, 2006, at 7:35 AM, Scott Fleckenstein wrote:

Thanks for your time,
Scott Fleckenstein

Looks pretty cool Scott, I like it.

Cheers-
– Ezra Z.
– Lead Rails Evangelist
[email protected]
– Engine Y., Serious Rails Hosting
– (866) 518-YARD (9273)

Yes, it’s brilliant, could you explain why it works just with 1.2RC

Thanks

Paolo

It only works in rails 1.2 RC because I use alias_method_chain as well
as add “RAILS_ROOT/app/errors” to the Dependency.load_paths so that you
get nice autoloading and such for custom errors.

I suppose I could work around those in an update that extends
compatability to 1.1.6

-Scott

An Update:

I’ve extended Exceptional to support 1.1.6, with a few addenda. First,
I cannot reliably distinguish between versions of rails if you have
frozen rails in your application. I can’t use Rails version defined in
version.rb because it is the same between 1.2RC and 1.1.6, and so I
have to rely on rubygems to decide whether I should include the
compatability patches.

Speaking of them, the are all simply included in a file called
compatability_116.rb for easy removal. I would desire to remove these
patches as 1.2 goes final for the simple fact that to get the handles
directive to catch routing errors, I have to redefine
Dispatcher.dispatch to use the version in the RC. Doing so makes me
feel really icky.

Anyways, patches are welcome to add support for frozen installations of
1.1.6.

Thanks,
Scott