开发者

Rails: Catch REXML Request Parameter Parse Error in POST

开发者 https://www.devze.com 2023-01-02 17:00 出处:网络
I have a REST API which accepts XML in HTTP Posts. When I send wellformed XML, the XML is parsed and put in the params object.

I have a REST API which accepts XML in HTTP Posts.

When I send wellformed XML, the XML is parsed and put in the params object. For instance:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<foo>
  <bar>Hello</bar>
</foo&g开发者_开发技巧t;

is available as: "foo"=>{"bar"=>"Hello"}}

But when I send malformed XML, Rails logs a REXML::ParseException and returns the HTML for this "Something went wrong"-site.

How can I catch this Exception so that I can respond with something more useful?


Apparently this is a known problem. One solution could be http://github.com/kares/request_exception_handler

0

精彩评论

暂无评论...
验证码 换一张
取 消