Exception: Blodsband::Multi::Error

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/blodsband/multi.rb

Overview

An error that collects all errors in a single Blodsband::Multi and renders them in a readable way.

Instance Method Summary collapse

Constructor Details

#initialize(multi) ⇒ Error

Returns a new instance of Error.



10
11
12
13
14
15
16
# File 'lib/blodsband/multi.rb', line 10

def initialize(multi)
  @bad = {}
  @bad.merge!(multi.responses[:errback])
	multi.responses[:callback].each do |key, value|
    @bad[key] = value unless [200,204].include?(value.response_header.status)
	end
end

Instance Method Details

#to_sObject



17
18
19
20
21
22
23
24
25
# File 'lib/blodsband/multi.rb', line 17

def to_s
  @bad.values.inject([]) do |sum, http|
    if http.response_header.status == 0
      sum + ["Connection timed out: #{http.req.uri}"]
    else
      sum + ["#{http.response_header.status}: #{http.response}"]
    end
  end.join("\n")
end