ohler55 / oj

Optimized JSON
http://www.ohler.com/oj
MIT License
3.12k stars 250 forks source link

Getting `TypeError: wrong argument type nil (expected Class)` instead of expected `Oj::ParseError` #896

Closed jasonpenny closed 10 months ago

jasonpenny commented 10 months ago

Attempting to parse invalid JSON was previously raising Oj::ParseError, but is now raising TypeError

> # v3.14.2 gives expected error type
> Oj.load("64ecb72d29191067f91ff95b")
Oj::ParseError: Invalid float

> # v3.15+
> Oj.load("64ecb72d29191067f91ff95b")
TypeError: wrong argument type nil (expected Class)

I think this comes from this change, where ni->pi->err_class is sometimes nil:

https://github.com/ohler55/oj/commit/980aa8340b8e06324257b9f3b28e2c0a20da0b29#diff-768e5543d34fbb4844c925b85ec9e53398e3ebcfb7d24010784cd920666534beL877-R878