Skip to content

Commit

Permalink
When payloads get truncated in the DB due to encoding issues, at leas…
Browse files Browse the repository at this point in the history
…t do not blow up on reading them
  • Loading branch information
cantino committed Oct 1, 2015
1 parent 9c58474 commit 797e7e3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/json_with_indifferent_access.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
class JSONWithIndifferentAccess
def self.load(json)
ActiveSupport::HashWithIndifferentAccess.new(JSON.parse(json || '{}'))
rescue JSON::ParserError
Rails.logger.error "Unparsable JSON in JSONWithIndifferentAccess: #{json}"
{ 'error' => 'unparsable json detected during de-serialization' }
end

def self.dump(hash)
Expand Down

0 comments on commit 797e7e3

Please sign in to comment.