From f0d38b06cbdcfd59494c220e6f4685f2e5aa38fd Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 29 Feb 2012 15:06:27 +0000 Subject: logging in error.rb, dynamic class methods in rest-client-wrapper.rb --- lib/error.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'lib/error.rb') diff --git a/lib/error.rb b/lib/error.rb index 1866585..b832ef4 100644 --- a/lib/error.rb +++ b/lib/error.rb @@ -1,6 +1,15 @@ # adding additional fields to Exception class to format errors according to OT-API +=begin class Exception +end +=end + +class RuntimeError attr_accessor :errorCause # is errorReport + def initialize msg=nil + $logger.error msg + super msg + end def http_code; 500; end end @@ -26,13 +35,15 @@ module OpenTox def http_code; 503; end end - # TODO: add to RestClientCalls class RestCallError < RuntimeError - attr_accessor :rest_params + def initialize request, response, expectation=nil + msg = "REST request: #{request.inspect}\nREST response: #{response.inspect}" + msg += "\n"+expectation if expectation + super msg + end def http_code; 502; end end - # TODO: add to Exception class?? class ErrorReport # TODO replace params with URIs (errorCause -> OT.errorCause) -- cgit v1.2.3