diff --git a/lib/raven/okjson.rb b/lib/raven/okjson.rb index 2fda91719..64c79268b 100644 --- a/lib/raven/okjson.rb +++ b/lib/raven/okjson.rb @@ -499,7 +499,7 @@ def strenc(s) def numenc(x) if ((x.nan? || x.infinite?) rescue false) - raise Error, "Numeric cannot be represented: #{x}" + return strenc(x.to_s) end "#{x}" end diff --git a/spec/raven/okjson_spec.rb b/spec/raven/okjson_spec.rb index b88fdc844..138041107 100644 --- a/spec/raven/okjson_spec.rb +++ b/spec/raven/okjson_spec.rb @@ -23,9 +23,11 @@ it 'encodes anything that responds to to_s' do data = [ (1..5), - :symbol + :symbol, + 1/0.0, + 0/0.0 ] - expect(Raven::OkJson.encode(data)).to eq "[\"1..5\",\"symbol\"]" + expect(Raven::OkJson.encode(data)).to eq "[\"1..5\",\"symbol\",\"Infinity\",\"NaN\"]" end it 'does not parse scientific notation' do