skyfallsin-ruby_bosh 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/ruby_bosh.rb +6 -2
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/ruby_bosh.rb
CHANGED
@@ -3,6 +3,7 @@ require 'builder'
|
|
3
3
|
require 'rexml/document'
|
4
4
|
require 'base64'
|
5
5
|
require 'hpricot'
|
6
|
+
require 'timeout'
|
6
7
|
require 'system_timer'
|
7
8
|
|
8
9
|
class RubyBOSH
|
@@ -14,6 +15,7 @@ class RubyBOSH
|
|
14
15
|
|
15
16
|
class Timeout < StandardError; end
|
16
17
|
class AuthFailed < StandardError; end
|
18
|
+
class ConnFailed < StandardError; end
|
17
19
|
|
18
20
|
attr_accessor :jid, :rid, :sid, :success
|
19
21
|
def initialize(jid, pw, service_url, opts={})
|
@@ -124,8 +126,10 @@ class RubyBOSH
|
|
124
126
|
send(xml)
|
125
127
|
recv(RestClient.post(@service_url, xml, @headers))
|
126
128
|
end
|
127
|
-
rescue Timeout::Error => e
|
128
|
-
raise
|
129
|
+
rescue ::Timeout::Error => e
|
130
|
+
raise RubyBOSH::Timeout, e.message
|
131
|
+
rescue Errno::ECONNREFUSED => e
|
132
|
+
raise RubyBOSH::ConnFailed, "could not connect to #{@host}\n#{e.message}"
|
129
133
|
end
|
130
134
|
|
131
135
|
def send(msg)
|