diff options
author | mguetlein <martin.guetlein@gmail.com> | 2013-08-16 10:35:03 +0200 |
---|---|---|
committer | mguetlein <martin.guetlein@gmail.com> | 2013-08-16 10:35:03 +0200 |
commit | 22b353110299ab819fc53cd83b456caa35900508 (patch) | |
tree | ca0112534d1b6ec53d40fe2e7a04470533b2742b | |
parent | a5904f0c097df8d53bfdf0b4a8209e953700d489 (diff) |
fix error handling when non-ot-errors are returned (like e.g. from the 4store)
-rw-r--r-- | lib/rest-client-wrapper.rb | 5 |
1 files 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 |