small medium large xlarge

02 Jun 2009, 23:25
Bjarki Gudlaugsson (1 post)


I’m having a small problem with catching the ActiveRecord::RecordNotFound exceptions. When I run the curl command from the second screencast I don’t get the clean output from the screencast. Instead I get the entire Sinatra exception page containing the ActiveRecord::RecordNotFound. I am using the code in the episode 2 tgz file.

This is the command:

curl –url http://localhost:4567/asides/1212.json

Any ideas what I am doing wrong?

Also, why do I have to restart Sinatra every time I do a change in order for it to recognize the new code? Something about development mode I am not getting?

Thanks in advance, Bjarki

p.s. I am on a mac os x leopard machine with version 0.9.2 of Sinatra

16 Jun 2009, 21:30
Gonzalo Suárez (1 post)

As far as I know, Sinatra 0.9.2 doesn’t reload in development mode any more. You have to apply a patch in order to get this feature working.

On the other hand, Sinatra 0.9.2 (development mode) won’t pass an exception (i.e. ActiveRecord::RecordNotFound) to “error” built-in helper. Instead it shows an error page. This is a weird behaviour for a REST web service so to turn this feature off add this to your app:

set :show_exceptions, false

By the way, :show_exceptions is already false when you run Sinatra in production mode.

You must be logged in to comment