Rohde-Schwarz / sparrow

Define your request and response JSON format with a Rack middleware!
MIT License
13 stars 6 forks source link

Uncaught parse exceptions #22

Closed tuwilof closed 3 years ago

tuwilof commented 8 years ago

Hi, we use your gem and recently faced with the problem. When we send an incorrect json in the post request we get these errors in the log.

app error: "822: unexpected token at '{\r\n\u{201c}login\u{201d}:\u{201d}user\u{201d}\r\n\u{201c}password\u{201d}:\u{201d}123\u{201d}\r\n}\r\n'" (MultiJson::ParseError)
/usr/local/rbenv/versions/2.3.0-p0/lib/ruby/2.3.0/json/common.rb:156:in `parse'
/usr/local/rbenv/versions/2.3.0-p0/lib/ruby/2.3.0/json/common.rb:156:in `parse'
/shared/bundle/ruby/2.3.0/gems/multi_json-1.11.2/lib/multi_json/adapters/json_common.rb:14:in `load'
/shared/bundle/ruby/2.3.0/gems/multi_json-1.11.2/lib/multi_json/adapter.rb:21:in `load'
/shared/bundle/ruby/2.3.0/gems/multi_json-1.11.2/lib/multi_json.rb:119:in `load'
/shared/bundle/ruby/2.3.0/gems/cp-sparrow-0.0.14/lib/sparrow/transformable.rb:47:in `ensure_json'
/shared/bundle/ruby/2.3.0/gems/cp-sparrow-0.0.14/lib/sparrow/transformable.rb:22:in `rescue in json_body'
/shared/bundle/ruby/2.3.0/gems/cp-sparrow-0.0.14/lib/sparrow/transformable.rb:18:in `json_body'
/shared/bundle/ruby/2.3.0/gems/cp-sparrow-0.0.14/lib/sparrow/strategies/raw_input.rb:62:in `handle_raw_rack'
/shared/bundle/ruby/2.3.0/gems/cp-sparrow-0.0.14/lib/sparrow/strategies/raw_input.rb:40:in `handle'
/shared/bundle/ruby/2.3.0/gems/cp-sparrow-0.0.14/lib/sparrow/strategies/raw_input.rb:20:in `handle'
/shared/bundle/ruby/2.3.0/gems/cp-sparrow-0.0.14/lib/sparrow/request_middleware.rb:5:in `convert'
/shared/bundle/ruby/2.3.0/gems/cp-sparrow-0.0.14/lib/sparrow/middleware.rb:33:in `call'