lib/eco/api/session/batch/errors.rb in eco-helpers-1.1.2 vs lib/eco/api/session/batch/errors.rb in eco-helpers-1.1.3
- old
+ new
@@ -36,17 +36,17 @@
def logger
status.logger
end
- # Was there any **error** as a result of this batch?
+ # Was there any _Sever_ (reply) **error** as a result of this batch?
# @return [Boolean] `true` if any of the queried _entries_ got an unsuccessful `Ecoportal::API::Common::BatchResponse`
def any?
queue.any? {|query| !status[query].success?}
end
- # Input entries that got launched against the server.
+ # Input entries that got **error** response from the _Server_.
# @raise [Exception] if there are elements of the final `queue` that did not get response
# @note discards those that did not get _response_ from the Server (so those that were not queried)
# - please, observe that this can only happen if there were repeated entries in the `source_queue`
# @return [Array<Hash>, Array<Ecoportal::API::V1::Person>, Array<Ecoportal::API::Internal::Person>]
def entries
@@ -61,11 +61,11 @@
end
end
raise msg
end
- response.success? ? nil : query
+ response.success?? nil : query
end.compact
end
def errors
entries.each_with_object([]) do |entry, arr|
@@ -115,13 +115,21 @@
unless status.success?(key)
logger.error(str(key))
end
end
+ def message
+ msgs = strs
+ if msgs.length > 0
+ "There were #{msgs.length} errors:\n" + msgs.join("\n")
+ else
+ "There were no errors for the current batch '#{method}'!! ;)"
+ end
+ end
+
def print
msgs = strs
if msgs.length > 0
- logger.info()
logger.error("There were #{msgs.length} errors:\n" + msgs.join("\n"))
else
logger.info("There were no errors for the current batch '#{method}'!! ;)")
end
end