defaulting :show_exceptions to true in Sinatra 0.9.2 when in development assumes that html formatted error is appropriate, but is not appropriate for xml/etc. web services

457 views
Skip to first unread message

gsw

unread,
Jun 5, 2009, 5:11:11 PM6/5/09
to sinatrarb
Hello,

Having :show_exceptions default to true in Sinatra 0.9.2 is causing
two issues currently:

1. This assumes that Sinatra is serving a site with a human interface,
which is not the case in our application. We were relying on the error
block to catch all errors and return a properly formatted and "header-
ed" XML response, even for development, so we're having to manually
set :show_exceptions, false. We are extending Sinatra::Base, but I
don't think that has anything to do with it, because Sinatra::Default
(and therefore Sinatra::Application) didn't set :show_exceptions
either).

2. We're having some trouble with warbler and rack knowing that it
should be in production, i.e. the set :environment, :production that
is in the config.ru that Nick provided as an example rackup for
Sinatra does not seem to be getting it into production mode. So for
this reason we really must set :show_exceptions, false in our sinatra
controllers that extend Sinatra::Base.

I think that at the least, maybe some additional documentation for
those whose intent it is to have Sinatra provide non-HTML serving app/
services (even in development mode when error is being thrown), and
possibly even consider changing :show_exceptions to always be false by
default even in development. I could assist with the documentation if
you wanted to provide guidance. I saw the git project for the docs,
and could provide a draft offline if you wanted.

If I'm way off-base, I apologize, but even though I like the look of
the HTML error produced, it doesn't work for everyone.

TIA,
Gary

Ryan Tomayko

unread,
Jun 5, 2009, 10:51:22 PM6/5/09
to sina...@googlegroups.com

The :show_exceptions option should definitely be disabled by default
for Sinatra::Base subclasses in all environments. Here's the offending
code:

http://github.com/sinatra/sinatra/blob/9de67b15c6040f9a5d864a4db2dc7f5c9665f462/lib/sinatra/base.rb#L980

I'm not sure how that slipped in there.

The option should remain enabled by default in development for
top-level apps (i.e., Sinatra::Application).

Thanks,
Ryan

Reply all
Reply to author
Forward
0 new messages