I have my own error message for 400 status code:
get '/do' do raise ParamXMissingError unless params['x'] end error ParamXMissingError do haml :custom_error_page end
I want ParamXMissingError to be 400, but when I run the above code and check the Firefox network tools, it seems that Sinatra is actually returning 500, not 400. How do I display custom_error_page.haml and return 400?
Preferably, it would be nice to have a status code and a page processed inside the error block, rather than what I would splatter when raising ParamXMissingError . For example, this would be a repetitive and not a good solution: halt 400, haml(:custom_error_page)
garbagecollector
source share