Flowdock
method

parse_error

Importance_1
Ruby on Rails latest stable (v4.0.2) - 0 notes - Class: ActiveSupport::JSON
parse_error() public

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
Show source
Register or log in to add new notes.