lib/acfs/errors.rb in acfs-0.21.0 vs lib/acfs/errors.rb in acfs-0.21.1.b189
- old
+ new
@@ -14,11 +14,11 @@
class ErroneousResponse < Error
attr_reader :response
def initialize(opts = {})
@response = opts[:response]
- message = 'Received erroneous response'
+ message = opts[:message] || 'Received erroneous response'
if response
message << ": #{response.code}"
if response.data
message << "\n with content:\n "
message << response.data.map{|k,v| "#{k.inspect}: #{v.inspect}"}.join("\n ")
@@ -62,9 +62,11 @@
attr_reader :errors, :resource
def initialize(opts = {})
@errors = opts.delete :errors
@resource = opts.delete :resource
+ opts[:message] ||= @errors.map{ |k,v| "#{k}: #{v.join ', '}" }.join ', ' if @errors.is_a? Hash
+ opts[:message] ||= @errors.join ', ' if @errors.is_a? Array
super
end
end
# A ResourceNotLoaded error will be thrown when calling some