Sha256: 478f8f5869f44bd66b780f4245fcf36df8846d23d0d77b2c2adb38359e197652

Contents?: true

Size: 593 Bytes

Versions: 98

Compression:

Stored size: 593 Bytes

Contents

module ZuoraConnect
  class JsonParseErrors
    def initialize(app)
      @app = app
    end

    def call(env)
      begin
        @app.call(env)
      rescue ActionDispatch::ParamsParser::ParseError => error
        if env['HTTP_ACCEPT'] =~ /application\/json/ || env['CONTENT_TYPE'] =~ /application\/json/
          return [
            400, { "Content-Type" => "application/json" },
            [{"success": false, "reasons": [{"code": 50000090, "message": "Malformed json was submitted." }]}.to_json ]
          ]
        else
          raise error
        end
      end
    end
  end
end

Version data entries

98 entries across 98 versions & 1 rubygems

Version Path
zuora_connect-2.1.1 lib/middleware/json_parse_errors.rb
zuora_connect-2.0.60c lib/middleware/json_parse_errors.rb
zuora_connect-2.0.60b lib/middleware/json_parse_errors.rb
zuora_connect-2.0.60a lib/middleware/json_parse_errors.rb
zuora_connect-2.0.60 lib/middleware/json_parse_errors.rb
zuora_connect-2.0.59a lib/middleware/json_parse_errors.rb
zuora_connect-2.0.59 lib/middleware/json_parse_errors.rb
zuora_connect-2.0.58a lib/middleware/json_parse_errors.rb
zuora_connect-2.0.57zc lib/middleware/json_parse_errors.rb
zuora_connect-2.0.58 lib/middleware/json_parse_errors.rb
zuora_connect-2.0.57zb lib/middleware/json_parse_errors.rb
zuora_connect-2.0.57za lib/middleware/json_parse_errors.rb
zuora_connect-2.0.57z lib/middleware/json_parse_errors.rb
zuora_connect-2.0.57y lib/middleware/json_parse_errors.rb
zuora_connect-2.0.57x lib/middleware/json_parse_errors.rb
zuora_connect-2.0.57w lib/middleware/json_parse_errors.rb
zuora_connect-2.0.57v lib/middleware/json_parse_errors.rb
zuora_connect-2.0.57u lib/middleware/json_parse_errors.rb
zuora_connect-2.0.57t lib/middleware/json_parse_errors.rb
zuora_connect-2.0.57s lib/middleware/json_parse_errors.rb