# File lib/ec2/helpers/errors.rb, line 37 def error_for_code(code) case code when 401 then 'AuthFailure' when 500 then 'InternalError' else "Unavailable (#{code})" end end
# File lib/ec2/helpers/errors.rb, line 19 def report_error(code) error = (request.env['sinatra.error'] || @exception) code = 500 if not code and not error.class.method_defined? :code Nokogiri::XML::Builder.new do |xml| xml.send(:Response) { xml.send(:Errors) { xml.send(:Code, error_for_code(code)) xml.send(:Message, error.respond_to?(:message) ? error.message : '') } xml.send(:RequestID, request_id) } end.to_xml end
# File lib/ec2/helpers/errors.rb, line 33 def request_id Digest::MD5.hexdigest("#{request.env['REMOTE_ADDR']}#{request.env['HTTP_USER_AGENT']}#{Time.now.to_i}#{rand(250)}") end