Error block does not work in Sinatra application

I have the following Sinatra application and I am testing the error block, but it does not seem to work.

Here is my sinatra application:

 require 'rubygems' require 'sinatra' error do puts "----> Failed" $stdout.print "----> Failed" end get "/*" do raise "Error!!" end 

I use Sinatra (1.3.3)

+4
source share
3 answers

You can add:

 set :show_exceptions, false 

To the application file.

In development environments, show_exceptions enabled by default.

+6
source

Sinatra uses its own error handler when it is installed in development mode, which is the default. In order for your error to appear, you must run the application in production mode as follows:

 ruby my_app.rb -e production 

Here is a link to specific documentation for further reference: Sinatra README # Environment

+4
source

make sure you are not using the beta version of the rack

 gem list rack 

if you see something like the following:

 rack-1.6.0.beta 

Remove this version and use the previous version of rack-1.5.2

0
source

Source: https://habr.com/ru/post/1437084/


All Articles