我正在使用RestClient,并且由于我的参数被采用的方式,URL可能无法正确构建并且
RestClient::BadRequest
发出400错误。我怎样才能呈现视图?我想告诉用户他们的搜索没有返回任何结果。
我已经在https://github.com/rest-client/rest-client#exceptions-see-wwww3orgprotocolsrfc2616rfc2616-sec10html查阅了文档,但我仍然无法让它工作。
这就是我正在使用的:
begin
response = RestClient::Request.execute(method: :get, url: "[...]")
@result = JSON.parse(response)
rescue => e
@message = "Invalid search"
@result = {}
end
我哪里错了?