summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2010-06-01 10:49:28 +0200
committermguetlein <martin.guetlein@gmail.com>2010-06-01 10:49:28 +0200
commit593ab333363318ffddb00003ac846e8cfa8e6f44 (patch)
tree683181edb56d3e40d74003e175cf225255f469dd /lib
parentbf0a8faa9c08a2c1897545aa7d7150e236d6cdfe (diff)
adjust error handling for big error msgs
Diffstat (limited to 'lib')
-rw-r--r--lib/rest_client_wrapper.rb18
-rw-r--r--lib/task.rb1
2 files changed, 10 insertions, 9 deletions
diff --git a/lib/rest_client_wrapper.rb b/lib/rest_client_wrapper.rb
index 8e1beb4..83089d0 100644
--- a/lib/rest_client_wrapper.rb
+++ b/lib/rest_client_wrapper.rb
@@ -140,15 +140,15 @@ module OpenTox
error = [Error.new(code, body, uri, payload, headers)]
end
-# #debug utility: write error to file
-# error_dir = "/tmp/ot_errors"
-# FileUtils.mkdir(error_dir) unless File.exist?(error_dir)
-# raise "could not create error dir" unless File.exist?(error_dir) and File.directory?(error_dir)
-# file_name = "error"
-# time=Time.now.strftime("%m.%d.%Y-%H:%M:%S")
-# count = 1
-# count+=1 while File.exist?(File.join(error_dir,file_name+"_"+time+"_"+count.to_s))
-# File.new(File.join(error_dir,file_name+"_"+time+"_"+count.to_s),"w").puts(body)
+ #debug utility: write error to file
+ error_dir = "/tmp/ot_errors"
+ FileUtils.mkdir(error_dir) unless File.exist?(error_dir)
+ raise "could not create error dir" unless File.exist?(error_dir) and File.directory?(error_dir)
+ file_name = "error"
+ time=Time.now.strftime("%m.%d.%Y-%H:%M:%S")
+ count = 1
+ count+=1 while File.exist?(File.join(error_dir,file_name+"_"+time+"_"+count.to_s))
+ File.new(File.join(error_dir,file_name+"_"+time+"_"+count.to_s),"w").puts(body)
# handle error
# we are either in a task, or in sinatra
diff --git a/lib/task.rb b/lib/task.rb
index aace2be..1d2c4c2 100644
--- a/lib/task.rb
+++ b/lib/task.rb
@@ -78,6 +78,7 @@ module OpenTox
end
def error(description)
+ description = description[0..999] if description.to_s.size>1000
RestClientWrapper.put(File.join(@uri,'Error'),{:description => description})
reload
end