summaryrefslogtreecommitdiff
path: root/lib/error.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2012-03-13 20:52:45 +0100
committerChristoph Helma <helma@in-silico.ch>2012-03-13 20:52:45 +0100
commit625c88673e90053f898423dfc96bda1d6c0fa8eb (patch)
tree90c4178c3110983635d63f1570fb53ec932ada4f /lib/error.rb
parent9cf20c9fa99bac82c8a4e455eb6c97ecb3f26776 (diff)
short backtrace for errorDetails
Diffstat (limited to 'lib/error.rb')
-rw-r--r--lib/error.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/error.rb b/lib/error.rb
index e3329be..cc87f47 100644
--- a/lib/error.rb
+++ b/lib/error.rb
@@ -71,7 +71,14 @@ module OpenTox
@report[RDF::OT.message] = error.message.to_s
@report[RDF::OT.statusCode] = @http_code
@report[RDF::OT.errorCode] = error.class.to_s
- @report[RDF::OT.errorDetails] = caller.collect{|line| line unless line =~ /#{File.dirname(__FILE__)}/}.compact.join("\n")
+
+ # cut backtrace
+ backtrace = caller.collect{|line| line unless line =~ /#{File.dirname(__FILE__)}/}.compact
+ cut_index = backtrace.find_index{|line| line.match /sinatra|minitest/}
+ cut_index ||= backtrace.size
+ cut_index -= 1
+ cut_index = backtrace.size-1 if cut_index < 0
+ @report[RDF::OT.errorDetails] = backtrace[0..cut_index].join("\n")
@report[RDF::OT.errorDetails] += "REST paramenters:\n#{error.request.args.inspect}" if defined? error.request
@report[RDF::OT.message] += "\n" + error.response.body.to_s if defined? error.response
# TODO fix Error cause
@@ -85,6 +92,9 @@ module OpenTox
send :define_method, "to_#{format}".to_sym do
rdf = RDF::Writer.for(format).buffer do |writer|
+ # TODO: not used for turtle
+ # http://rdf.rubyforge.org/RDF/Writer.html#
+ writer.prefix :ot, RDF::URI('http://www.opentox.org/api/1.2#')
subject = RDF::Node.new
@report.each do |predicate,object|
writer << [subject, predicate, object] if object