lib/acfs/errors.rb in acfs-1.5.1 vs lib/acfs/errors.rb in acfs-1.6.0

- old
+ new

@@ -37,11 +37,11 @@ def initialize(opts = {}) @response = opts[:response] message = if response - (opts[:message] ? opts[:message] + ':' : 'Received') + + (opts[:message] ? "#{opts[:message]}:" : 'Received') + " #{response.code} for #{response.request.method.upcase}" \ " #{response.request.url} #{response.request.format}" else opts[:message] || 'Received erroneous response' end @@ -85,16 +85,17 @@ def initialize(opts = {}) @errors = opts.delete :errors @resource = opts.delete :resource - if @errors.is_a?(Hash) - opts[:message] ||= @errors.each_pair.map do |k, v| - @errors.is_a?(Array) ? "#{k}: #{v.join(', ')}" : "#{k}: #{v}" - end.join ', ' - elsif @errors.is_a?(Array) - opts[:message] ||= @errors.join ', ' + case @errors + when Hash + opts[:message] ||= @errors.each_pair.map do |k, v| + @errors.is_a?(Array) ? "#{k}: #{v.join(', ')}" : "#{k}: #{v}" + end.join ', ' + when Array + opts[:message] ||= @errors.join ', ' end super end end @@ -129,11 +130,10 @@ # Gets raised if ressource type is no valid subclass of # parent resource. Check if the type is set to the correct # Acfs::Resource Name class ResourceTypeError < Error - attr_reader :base_class - attr_reader :type_name + attr_reader :base_class, :type_name def initialize(opts = {}) @base_class = opts.delete :base_class @type_name = opts.delete :type_name opts[:message] = "Received resource type `#{type_name}` " \