From 59dba52a30de35da0122cd6c25777573faa5ffc3 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Mon, 24 Jan 2011 17:19:56 +0100 Subject: fix error handling --- lib/overwrite.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'lib/overwrite.rb') diff --git a/lib/overwrite.rb b/lib/overwrite.rb index 83d8099..4fa0829 100644 --- a/lib/overwrite.rb +++ b/lib/overwrite.rb @@ -19,8 +19,22 @@ error Exception do # log error to logfile LOGGER.error error.class.to_s+": "+error.message # log backtrace only if code is 500 -> unwanted (Runtime)Exceptions and internal errors (see error.rb) - LOGGER.error error.backtrace.join("\n") if error.http_code==500 - halt error.http_code,OpenTox::ErrorReport.format(error,request,response) + LOGGER.error ":\n"+error.backtrace.join("\n") if error.http_code==500 + + actor = "#{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}#{request.env['REQUEST_URI']}" + rep = OpenTox::ErrorReport.new(error, actor) + + case request.env['HTTP_ACCEPT'] + when /rdf/ + content_type 'application/rdf+xml' + halt error.http_code,rep.to_xml + when /html/ + content_type 'text/html' + halt error.http_code,(OpenTox.text_to_html rep.to_yaml) + else + content_type 'application/x-yaml' + halt error.http_code,rep.to_yaml + end end class String -- cgit v1.2.3