Ruby and Sinatra

I started writing a simple Sinatra application today and I am trying to understand the error report, but for some reason I cannot get it to work correctly.

I know here http://railsapi.com/doc/sinatra-v1.0/ , it talks about working with error handling / error handling, but when I run my examples, I cannot get it working.

require 'sinatra'

error 400..510 do
  'Boom'
end

get '/say/*' do
  params[:splat]
end

When I run the application on my computer, I get an error code 404, but the text 'Boom'does not appear in the browser, but only on the browser page 404. I am sure that I am doing something wrong, but I just can’t understand.

+3
source share
2 answers

I set my browser. On my MacBook Pro:

Chrome "" "! , , ". .

Safari Boom.

Firefox Boom.

+4

, Sinatra Sinatra:: NotFound (404) . :

require 'sinatra'

not_found do
  'Boom in NOT_FOUND.'
end

error 400..510 do
  'Boom'
end

get '/say/*' do
  params[:splat]
end

Chrome Firefox Mac OSX.

0

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


All Articles