From f2ca545448ab8a6f654309f23cfce9416b2e9856 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Thu, 13 Jan 2011 14:02:58 +0100 Subject: find methods for algorithm and model, split method for dataset, feature_type method for model and feature, perform single predicitons in resuce block, add to-html.rb, fix handling of rest-client-wrapper --- lib/overwrite.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lib/overwrite.rb') diff --git a/lib/overwrite.rb b/lib/overwrite.rb index 8d787a6..e5ed5c3 100644 --- a/lib/overwrite.rb +++ b/lib/overwrite.rb @@ -2,6 +2,22 @@ # hack: store sinatra in global var to make url_for and halt methods accessible before{ $sinatra = self unless $sinatra } +# handle errors manually +# this is to return 502, when an error occurs during a rest-call (see rest_client_wrapper.rb) +set :raise_errors, Proc.new { false } +set :show_exceptions, false +error do + # try if the error is an OpenTox::Error + if OpenTox::Error.parse(request.env['sinatra.error'].to_s) + # if true, this error comes from rest_client_wrapper, halt with 502 + # (502 is defined in OT API as Error coming from other service) + halt 502,request.env['sinatra.error'] + else + # else, raise exception, this will return 500 = internal error + raise request.env['sinatra.error'] + end +end + class Sinatra::Base # overwriting halt to log halts (!= 202) def halt(*response) @@ -60,7 +76,7 @@ class OTLogger < Logger n = 2 line = lines[n] - while (line =~ /spork.rb/ or line =~ /create/ or line =~ /ot-logger.rb/) + while (line =~ /spork.rb/ or line =~ /create/ or line =~ /overwrite.rb/) n += 1 line = lines[n] end -- cgit v1.2.3