Permalink
Browse files

Document ActiveSupport::JSON.parse_error [ci skip]

  • Loading branch information...
mark-rushakoff committed Jun 6, 2012
1 parent 1790b23 commit 5907b0b7f28132eb27a084536ee7766914bcc3a1
Showing with 8 additions and 0 deletions.
  1. +8 −0 activesupport/lib/active_support/json/decoding.rb
@@ -39,6 +39,14 @@ def with_backend(name)
self.backend = old_backend
end
+ # 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
def parse_error
MultiJson::DecodeError
end

0 comments on commit 5907b0b

Please sign in to comment.