summaryrefslogtreecommitdiff
path: root/lib/overwrite.rb
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2011-01-13 14:02:58 +0100
committermguetlein <martin.guetlein@gmail.com>2011-01-13 14:02:58 +0100
commitf2ca545448ab8a6f654309f23cfce9416b2e9856 (patch)
treedb97da6b26689585ab2d51467ec72a6999e32cd8 /lib/overwrite.rb
parentc923250bccd4023447feb46935f3b59ce5cfb843 (diff)
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
Diffstat (limited to 'lib/overwrite.rb')
-rw-r--r--lib/overwrite.rb18
1 files changed, 17 insertions, 1 deletions
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