From 5907b0b7f28132eb27a084536ee7766914bcc3a1 Mon Sep 17 00:00:00 2001 From: Mark Rushakoff Date: Tue, 5 Jun 2012 20:42:08 -0700 Subject: Document ActiveSupport::JSON.parse_error [ci skip] --- activesupport/lib/active_support/json/decoding.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/json/decoding.rb b/activesupport/lib/active_support/json/decoding.rb index 72fd97ceee..e44939e78a 100644 --- a/activesupport/lib/active_support/json/decoding.rb +++ b/activesupport/lib/active_support/json/decoding.rb @@ -39,6 +39,14 @@ module ActiveSupport 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 -- cgit v1.2.3