Method: Exceptional::ExceptionData#to_json

Defined in:
lib/exceptional/exception_data.rb

#to_jsonObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/exceptional/exception_data.rb', line 36

def to_json
  begin
    to_hash.to_json
  rescue NoMethodError
    begin
      require 'json'
      return to_hash.to_json
    rescue StandardError => e                   
      Exceptional.logger.error(e.message)
      Exceptional.logger.error(e.backtrace)                    
      raise StandardError.new("You need a json gem/library installed to send errors to Exceptional (Object.to_json not defined). \nInstall json_pure, yajl-ruby, json-jruby, or the c-based json gem")
    end
  end
end