[rspec-users] [rspec-rails] Exception catching in controller

Justin Ko jko170 at gmail.com
Thu Feb 17 11:46:11 EST 2011



On Feb 17, 7:36 am, Avdi Grimm <gro... at inbox.avdi.org> wrote:
> On Wed, Feb 16, 2011 at 7:24 AM, Yuriy Naidyon <yuro... at gmail.com> wrote:
> > def some_action
> >   raise Exception if some_falsy_value
> > rescue
> >   @message = 'Error'
> > end
>
> Don't raise Exception. Raise some descendant of StandardError, like
> RuntimeError (the default if you don't specify a class) or (even
> better) your own StandardError-derived exception class.
>
> A straight-up exception will bypass all default "rescue" clauses and
> in general indicates that something has gone badly wrong and the
> program should end.
>
> --
> Avdi Grimmhttp://avdi.org
> _______________________________________________
> rspec-users mailing list
> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users

"A straight-up exception will bypass all default "rescue" clauses" - I
learn something everyday!


More information about the rspec-users mailing list