From 22b353110299ab819fc53cd83b456caa35900508 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Fri, 16 Aug 2013 10:35:03 +0200 Subject: fix error handling when non-ot-errors are returned (like e.g. from the 4store) --- lib/rest-client-wrapper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/rest-client-wrapper.rb b/lib/rest-client-wrapper.rb index 3ed41ad..94ff029 100644 --- a/lib/rest-client-wrapper.rb +++ b/lib/rest-client-wrapper.rb @@ -61,13 +61,14 @@ module OpenTox error = known_errors.collect{|e| e if e[:code] == response.code}.compact.first begin # errors are returned as error reports in turtle, try to parse content = {} - RDF::Reader.for(:turtle).new(response.to_s) do |reader| + RDF::Reader.for(:turtle).new(response) do |reader| reader.each_triple{|triple| content[triple[1]] = triple[2]} end msg = content[RDF::OT.message].to_s cause = content[RDF::OT.errorCause].to_s + raise if msg.size==0 && cause.size==0 # parsing failed rescue # parsing error failed, use complete content as message - msg = response.to_s + msg = "Could not parse error response from rest call '#{method}' to '#{uri}':\n#{response}" cause = nil end Object.method(error[:method]).call msg, uri, cause # call error method -- cgit v1.2.3