Method: ActiveSupport::JSON.parse_error
- Defined in:
- lib/active_support/json/decoding.rb
.parse_error ⇒ Object
Returns the class of the error that will be raised when there is an error in decoding JSON. Using this method means you won’t directly depend on the ActiveSupport’s JSON implementation, in case it changes in the future.
begin
obj = ActiveSupport::JSON.decode(some_string)
rescue ActiveSupport::JSON.parse_error
Rails.logger.warn("Attempted to decode invalid JSON: #{some_string}")
end
43 44 45 |
# File 'lib/active_support/json/decoding.rb', line 43 def parse_error ::JSON::ParserError end |