Sha256: bb9b2955482bee7e3a52051478e7192824e17b8ca8be626d6a9954e0d9f977bb
Contents?: true
Size: 942 Bytes
Versions: 102
Compression:
Stored size: 942 Bytes
Contents
module ZuoraConnect class JsonParseErrors def initialize(app) @app = app end def call(env) begin @app.call(env) rescue DynamicRailsError => 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 # Note(hartley): remove once the minimum supported version of Rails is 5.2 class DynamicRailsError < StandardError def self.===(exception) if Rails.version >= "5.2" exception.is_a?(ActionDispatch::Http::Parameters::ParseError) else exception.is_a?(ActionDispatch::ParamsParser::ParseError) end end end end end
Version data entries
102 entries across 102 versions & 1 rubygems