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

**URL:** <https://www.ruby-forum.com/t/ann-exceptional-1-0-a-new-style-of-handling-exceptions/77389>\
**Category:** Rails\
**Created:** [November 27, 2006, 4:37pm UTC](https://www.ruby-forum.com/t/ann-exceptional-1-0-a-new-style-of-handling-exceptions/77389 "2006-11-27T16:37:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Fleckenstein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@Scott\_Fleckenstein](https://www.ruby-forum.com/u/Scott_Fleckenstein)\
**Post date:** [November 27, 2006, 4:37pm UTC](https://www.ruby-forum.com/t/ann-exceptional-1-0-a-new-style-of-handling-exceptions/77389/1 "2006-11-27T16:37:59Z")

</div>

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](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](http://hg.nullstyle.com/raw/exceptional)

For More Info:  
[http://nullstyle.com/home/exceptional](http://nullstyle.com/home/exceptional)

To Browse The Source:  
[http://hg.nullstyle.com/exceptional](http://hg.nullstyle.com/exceptional)

Agile Web D. Plugin Page:  
[http://www.agilewebdevelopment.com/plugins/exceptional](http://www.agilewebdevelopment.com/plugins/exceptional)

Thanks for your time,  
Scott Fleckenstein

---

<div class="post-metadata">

**Author:** ![Scott\_Fleckenstein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@Scott\_Fleckenstein](https://www.ruby-forum.com/u/Scott_Fleckenstein)\
**Post date:** [November 27, 2006, 11:39pm UTC](https://www.ruby-forum.com/t/ann-exceptional-1-0-a-new-style-of-handling-exceptions/77389/2 "2006-11-27T23:39:05Z")

</div>

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  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)

---

<div class="post-metadata">

**Author:** ![Scott\_Fleckenstein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@Scott\_Fleckenstein](https://www.ruby-forum.com/u/Scott_Fleckenstein)\
**Post date:** [November 27, 2006, 11:51pm UTC](https://www.ruby-forum.com/t/ann-exceptional-1-0-a-new-style-of-handling-exceptions/77389/3 "2006-11-27T23:51:06Z")

</div>

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

Thanks

Paolo

---

<div class="post-metadata">

**Author:** ![Scott\_Fleckenstein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@Scott\_Fleckenstein](https://www.ruby-forum.com/u/Scott_Fleckenstein)\
**Post date:** [November 28, 2006, 5:51am UTC](https://www.ruby-forum.com/t/ann-exceptional-1-0-a-new-style-of-handling-exceptions/77389/4 "2006-11-28T05:51:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Scott\_Fleckenstein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@Scott\_Fleckenstein](https://www.ruby-forum.com/u/Scott_Fleckenstein)\
**Post date:** [November 29, 2006, 8:16am UTC](https://www.ruby-forum.com/t/ann-exceptional-1-0-a-new-style-of-handling-exceptions/77389/5 "2006-11-29T08:16:20Z")

</div>

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
