class Exception

We are opening up Exception and adding to_xml and to_json.

Public Instance Methods

exception_type() click to toggle source
# File lib/egregious/extensions/exception.rb, line 7
def exception_type
  self.class.to_s ? self.class.to_s.split("::").last : 'None'
end
to_json() click to toggle source
# File lib/egregious/extensions/exception.rb, line 15
def to_json
  "{\"error\":#{ActiveSupport::JSON.encode(self.message.gsub(/\r/, ' ').gsub(/\n/, ' ').squeeze(' '))}, \"type\":\"#{self.exception_type}\"}"
end
to_xml() click to toggle source
# File lib/egregious/extensions/exception.rb, line 11
def to_xml
  "<errors><error>#{HTMLEntities.new.encode(self.message)}</error><type>#{self.exception_type}</type></errors>"
end