aboutsummaryrefslogtreecommitdiffstats
path: root/lib/plum/client
diff options
context:
space:
mode:
Diffstat (limited to 'lib/plum/client')
-rw-r--r--lib/plum/client/client_session.rb13
-rw-r--r--lib/plum/client/decoders.rb16
-rw-r--r--lib/plum/client/legacy_client_session.rb10
3 files changed, 16 insertions, 23 deletions
diff --git a/lib/plum/client/client_session.rb b/lib/plum/client/client_session.rb
index 81d2341..88cf15b 100644
--- a/lib/plum/client/client_session.rb
+++ b/lib/plum/client/client_session.rb
@@ -21,8 +21,9 @@ module Plum
def succ
@plum << @socket.readpartial(16384)
- rescue => e
- fail(e)
+ rescue
+ close
+ raise
end
def empty?
@@ -73,15 +74,11 @@ module Plum
end
private
- def fail(exception)
- close
- raise exception
- end
-
def setup_plum
plum = ClientConnection.new(@socket.method(:write), @http2_settings)
plum.on(:connection_error) { |ex|
- fail(ex)
+ close
+ raise ex
}
plum.window_update(@http2_settings[:initial_window_size])
plum
diff --git a/lib/plum/client/decoders.rb b/lib/plum/client/decoders.rb
index e6d72e7..d68f27b 100644
--- a/lib/plum/client/decoders.rb
+++ b/lib/plum/client/decoders.rb
@@ -17,14 +17,14 @@ module Plum
def decode(chunk)
@inflate.inflate(chunk)
- rescue Zlib::Error => e
- raise DecoderError.new("failed to decode chunk", e)
+ rescue Zlib::Error
+ raise DecoderError.new("failed to decode chunk", $!)
end
def finish
@inflate.finish
- rescue Zlib::Error => e
- raise DecoderError.new("failed to finalize", e)
+ rescue Zlib::Error
+ raise DecoderError.new("failed to finalize", $!)
end
end
@@ -35,14 +35,14 @@ module Plum
def decode(chunk)
@stream.inflate(chunk)
- rescue Zlib::Error => e
- raise DecoderError.new("failed to decode chunk", e)
+ rescue Zlib::Error
+ raise DecoderError.new("failed to decode chunk", $!)
end
def finish
@stream.finish
- rescue Zlib::Error => e
- raise DecoderError.new("failed to finalize", e)
+ rescue Zlib::Error
+ raise DecoderError.new("failed to finalize", $!)
end
end
diff --git a/lib/plum/client/legacy_client_session.rb b/lib/plum/client/legacy_client_session.rb
index a12f582..9dea6cd 100644
--- a/lib/plum/client/legacy_client_session.rb
+++ b/lib/plum/client/legacy_client_session.rb
@@ -16,8 +16,9 @@ module Plum
def succ
@parser << @socket.readpartial(16384)
- rescue => e # including HTTP::Parser::Error
- fail(e)
+ rescue # including HTTP::Parser::Error
+ close
+ raise
end
def empty?
@@ -47,11 +48,6 @@ module Plum
end
private
- def fail(exception)
- close
- raise exception
- end
-
def consume_queue
return if @response || @requests.empty?