summaryrefslogtreecommitdiff
path: root/lib/overwrite.rb
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2011-01-24 17:19:56 +0100
committermguetlein <martin.guetlein@gmail.com>2011-01-24 17:19:56 +0100
commit59dba52a30de35da0122cd6c25777573faa5ffc3 (patch)
tree3ffe5534fb3f4ca4a801b45124a9966fe0f6d3dc /lib/overwrite.rb
parent0e759bee80e2668e1fec7b741a4ea18015f98b84 (diff)
fix error handling
Diffstat (limited to 'lib/overwrite.rb')
-rw-r--r--lib/overwrite.rb18
1 files changed, 16 insertions, 2 deletions
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