lib/eco/api/session/batch/errors.rb in eco-helpers-2.1.9 vs lib/eco/api/session/batch/errors.rb in eco-helpers-2.1.10

- old
+ new

@@ -82,21 +82,25 @@ # 4. `response` -> the original response from the server that carries the error def errors entries.each_with_object([]) do |entry, arr| response = status[entry] if body = response.body + errs = [] if errs = body["errors"] || body["error"] errs = [errs].flatten(1).compact - errs.each do |msg| - arr.push(ErrorCache.new( - klass = Eco::API::Error.get_type(msg), - klass.new(err_msg: msg, entry: entry, session: session), - entry, - response - )) - end end + if errs.empty? && !response.success? + errs = [body["response"]].flatten(1).compact + end + errs.each do |msg| + arr.push(ErrorCache.new( + klass = Eco::API::Error.get_type(msg), + klass.new(err_msg: msg, entry: entry, session: session), + entry, + response + )) + end end end end # @!group Messaging methods @@ -183,10 +187,9 @@ def print_one(key) unless status.success?(key) logger.error(str(key)) end end - end end end end end