Is there a way to override the sinatra default NotFound error page (\"Sinatra doesnt know this ditty\")? I want sinatra to show only a plain string as \"Method not found\" when
Perhaps a more graceful solution than that proposed in the accepted answer is to rescue only Sinatra::NotFound
, rather than using the error(404)
or not_found
styles.
error Sinatra::NotFound do
content_type 'text/plain'
[404, 'Not Found']
end
This prevents the "sinatra doesn't know this ditty" default page for routes that you haven't defined, but doesn't get in the way of explicit return [404, 'Something else']
-style responses.