views:

99

answers:

2

I have an application class

class MyApplication < Sinatra::Base
  # ... do something ...
end

and a config.ru file

# ... load libraries ...
run MyApplication

I usually use Passenger as my development environment which works perfectly fine for a normal – non-modular – Sinatra application. But in this case I have no error output instead I get the default internal server error page which isn't very helpful. Is there a way to enable the default error handling?

+1  A: 

Look in your web server error log.

Hongli
+2  A: 

I've been bothered by this same issue for quite a while and just finally figured out the magic incantation to bring the default error handling back. It turns out it has nothing to do with Passenger, but is instead caused by using Sinatra::Base instead of a classic (top-level) application. If you subclass Sinatra::Base, many of the options have different defaults. In this case, the option you need to change is:

set :show_exceptions, true if development?

If you'd also like to re-enable the (related) ability to use an in-app error handler, use:

set :raise_errors, false

Which allows the error do ... end block to work like it does in a classic app.

Additional information about the differences between the classic and Sinatra::Base apps can be found in this lighthouse ticket and there's some discussion of this specific difference in the google group.

Emily