On Tue, Oct 25, 2011 at 5:20 PM, Rajinder Yadav <devguy...@gmail.com> wrote:

> OK I figured out this is a bug with webbrick, it errors out and then
> crashes!
>
> I installed passenger + nginx and the code works as expected.
>

But not optimal I think.

If you replaced the lines

 rescue
     # SQLite3::ConstraintException

with

  rescue SQLite3::ConstraintException

I would expect your code to also work correctly for the 2 cases that:
* the id is unique and all is well
* there is a non-unique id (causing the SQLite3::ConstraintException)
  which will still be caught by the rescue

but ... if any of the 100 other possible reasons for exception
occur, you will not longer be blind to them...  I suggest catching
the most fine grained Exception class you can, so you are not
blind to other unexpected Exceptions.

HTH,

Peter

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to