diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-05-08 16:03:34 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-05-08 16:04:28 +0900 |
commit | 5337a2165365b1fd9d49cbd791b0b7960c78647b (patch) | |
tree | cc9f007895e25f457c36b0eb3647a0c0c38c8b89 /lib/plum | |
parent | 0c1db0fb1db8f66d627c5e24ba538a8f80d091d1 (diff) | |
download | plum-5337a2165365b1fd9d49cbd791b0b7960c78647b.tar.gz |
style: use $! if possibletopic/fix-coding-style
Use $! when rescuing StandardError.
Diffstat (limited to 'lib/plum')
-rw-r--r-- | lib/plum/client/client_session.rb | 13 | ||||
-rw-r--r-- | lib/plum/client/decoders.rb | 16 | ||||
-rw-r--r-- | lib/plum/client/legacy_client_session.rb | 10 | ||||
-rw-r--r-- | lib/plum/rack/listener.rb | 12 | ||||
-rw-r--r-- | lib/plum/rack/server.rb | 8 | ||||
-rw-r--r-- | lib/plum/rack/thread_pool.rb | 4 | ||||
-rw-r--r-- | lib/plum/stream.rb | 4 |
7 files changed, 30 insertions, 37 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? diff --git a/lib/plum/rack/listener.rb b/lib/plum/rack/listener.rb index ac60310..901642e 100644 --- a/lib/plum/rack/listener.rb +++ b/lib/plum/rack/listener.rb @@ -41,8 +41,8 @@ module Plum sess = LegacySession.new(svc, e, sock) sess.run rescue Errno::ECONNRESET, Errno::ECONNABORTED, EOFError # closed - rescue => e - svc.log_exception(e) + rescue + svc.log_exception $! ensure sock.close end @@ -103,8 +103,8 @@ module Plum sess = LegacySession.new(svc, e, sock) sess.run rescue Errno::ECONNRESET, Errno::ECONNABORTED, EOFError # closed - rescue => e - svc.log_exception(e) + rescue + svc.log_exception $! ensure sock.close if sock end @@ -172,8 +172,8 @@ module Plum sess = Session.new(svc, sock, plum) sess.run rescue Errno::ECONNRESET, Errno::ECONNABORTED, EOFError # closed - rescue => e - svc.log_exception(e) + rescue + svc.log_exception $! ensure sock.close if sock end diff --git a/lib/plum/rack/server.rb b/lib/plum/rack/server.rb index 3091246..5ab2e71 100644 --- a/lib/plum/rack/server.rb +++ b/lib/plum/rack/server.rb @@ -33,14 +33,14 @@ module Plum begin svr.accept(self) rescue Errno::ECONNRESET, Errno::ECONNABORTED # closed - rescue => e - log_exception(e) + rescue + log_exception $! end } end rescue Errno::EBADF # closed - rescue => e - log_exception(e) + rescue + log_exception $! end end #} diff --git a/lib/plum/rack/thread_pool.rb b/lib/plum/rack/thread_pool.rb index 45ee3ae..68ce2b6 100644 --- a/lib/plum/rack/thread_pool.rb +++ b/lib/plum/rack/thread_pool.rb @@ -24,8 +24,8 @@ module Plum job, err = @jobs.pop begin job.call - rescue => e - err << e if err + rescue + err << $! if err end end } diff --git a/lib/plum/stream.rb b/lib/plum/stream.rb index 3cf3ba1..823a41a 100644 --- a/lib/plum/stream.rb +++ b/lib/plum/stream.rb @@ -156,8 +156,8 @@ module Plum begin decoded_headers = @connection.hpack_decoder.decode(payload) - rescue => e - raise RemoteConnectionError.new(:compression_error, e) + rescue + raise RemoteConnectionError.new(:compression_error, $!) end callback(:headers, decoded_headers) |