```ruby
require 'resque/coder'
require 'json'

module Resque
  # Sweet jruby --1.8 hax.
  if defined?(Encoding)
    # >= 1.9 Support
    ENCODING_EXCEPTION = Encoding::UndefinedConversionError
  else
    # ~> 1.8.7 Support
    ENCODING_EXCEPTION = JSON::GeneratorError
  end

  # The default coder for JSON serialization
  class JsonCoder < Coder
    # @param object (see Resque::Coder#encode)
    # @raise (see Resque::Coder#encode)
    # @return (see Resque::Coder#encode)
    def encode(object)
      JSON.dump object
    rescue ENCODING_EXCEPTION => e
      raise EncodeException, e.message, e.backtrace
    end

    # @param object (see Resque::Coder#decode)
    # @raise (see Resque::Coder#decode)
    # @return (see Resque::Coder#decode)
    def decode(object)
      return unless object
      JSON.load object
    rescue JSON::ParserError => e
      raise DecodeException, e.message, e.backtrace
    end
  end
end
```

Add wrapper for JSON encoding exceptions because yay consistency
user
```ruby
require 'resque/coder'
require 'json'

module Resque
  # The default coder for JSON serialization
  class JsonCoder < Coder

    # Different exceptions in different environments.
    # This wrapper attempts to mitigate that.
    module MultiEncodeExceptionWrapper
      def self.===(exception)
        if defined?(Encoding)
          return true if Encoding::UndefinedConversionError === exception
        end
        JSON::GeneratorError === exception
      end
    end

    # @param object (see Resque::Coder#encode)
    # @raise (see Resque::Coder#encode)
    # @return (see Resque::Coder#encode)
    def encode(object)
      JSON.dump object
    rescue MultiEncodeExceptionWrapper => e
      raise EncodeException, e.message, e.backtrace
    end

    # @param object (see Resque::Coder#decode)
    # @raise (see Resque::Coder#decode)
    # @return (see Resque::Coder#decode)
    def decode(object)
      return unless object
      JSON.load object
    rescue JSON::ParserError => e
      raise DecodeException, e.message, e.backtrace
    end
  end
end
```
assistant