diff options
author | Mark Rushakoff <mark.rushakoff@gmail.com> | 2012-06-05 20:42:08 -0700 |
---|---|---|
committer | Mark Rushakoff <mark.rushakoff@gmail.com> | 2012-06-05 20:42:08 -0700 |
commit | 5907b0b7f28132eb27a084536ee7766914bcc3a1 (patch) | |
tree | 1d194d39ec7d8d26f11cebf14cc3d67f3c1d02f6 /activesupport/lib | |
parent | 1790b234e4354c8aa2f1704bd80300c511ffd1ca (diff) | |
download | rails-5907b0b7f28132eb27a084536ee7766914bcc3a1.tar.gz rails-5907b0b7f28132eb27a084536ee7766914bcc3a1.tar.bz2 rails-5907b0b7f28132eb27a084536ee7766914bcc3a1.zip |
Document ActiveSupport::JSON.parse_error [ci skip]
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/json/decoding.rb | 8 |
1 files changed, 8 insertions, 0 deletions
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 |