Custom Error Handling in Sinatra

Quick note for future reference:

Sinatra will ordinarily enable :raise_errors when :environment is :production. From my reading of the code, this causes Sinatra not to attempt to handle exceptions but to let them bubble up to the surrounding Rack container. In this situation, error-handling directives like

error do
    @error_msg = request.env['sinatra.error']
    haml :error_page

have no effect.

In order to fix the problem, just explicitly disable :raise_errors in the Sinatra application.