lib/rest-client-wrapper.rb in lazar-0.0.7 vs lib/rest-client-wrapper.rb in lazar-0.0.9
- old
+ new
@@ -24,19 +24,18 @@
[:head,:get,:post,:put,:delete].each do |method|
define_singleton_method method do |uri,payload={},headers={},waiting_task=nil|
# check input
- bad_request_error "Headers are not a hash: #{headers.inspect}", uri unless headers==nil or headers.is_a?(Hash)
+ bad_request_error "Headers are not a hash: #{headers.inspect} for #{uri}." unless headers==nil or headers.is_a?(Hash)
headers[:subjectid] ||= @@subjectid
- bad_request_error "Invalid URI: '#{uri}'", uri unless URI.valid? uri
- #resource_not_found_error "URI '#{uri}' not found.", uri unless URI.accessible?(uri, @subjectid) unless URI.ssl?(uri)
+ bad_request_error "Invalid URI: '#{uri}'" unless URI.valid? uri
# make sure that no header parameters are set in the payload
[:accept,:content_type,:subjectid].each do |header|
if defined? $aa || URI(uri).host == URI($aa[:uri]).host
else
- bad_request_error "#{header} should be submitted in the headers", uri if payload and payload.is_a?(Hash) and payload[header]
+ bad_request_error "#{header} should be submitted in the headers of URI: #{uri}" if payload and payload.is_a?(Hash) and payload[header]
end
end
# create request
args={}
@@ -70,10 +69,10 @@
raise if msg.size==0 && cause.size==0 # parsing failed
rescue # parsing error failed, use complete content as message
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
+ Object.method(error[:method]).call "#{msg}, #{uri}, #{cause}" # call error method
else
response
end
end
end