开发者

Rails: Catch REXML Request Parameter Parse Error in POST

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜