sinatra (= 1.4.5)
I want to render a custom 404 message for specific routes, in this case, the text 'Not found'
class App < Sinatra::Application
not_found do
'You suck'
end
get '/404page' do
halt 404, 'Not found'
end
end
I have found that no matter what I do, the text from the not_found block is invoked any time response status is set to 404, when all I really want is the text from the halt.
May be a duplicate of Override Sinatra default NotFound error page but I have not been able to find the soution.
Overriding error Sinatra::NotFound seems to be a better choice to handle 404 when a specific route is not found.
error Sinatra::NotFound do
'You suck'
end
get '/404page' do
halt 404, 'Not found'
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With