class method
self.parse_error
Ruby on Rails 5.1.7
Since v3.1.12Signature
self.parse_error()
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
Source
# File activesupport/lib/active_support/json/decoding.rb, line 40
def parse_error
::JSON::ParserError
end
Defined in activesupport/lib/active_support/json/decoding.rb line 40
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::JSON