From dc10c8b4a1f7ef3a166352c911c40a3f1027056a Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Tue, 14 Sep 2021 21:14:26 -0700 Subject: [PATCH] [fix] Read server response during EPIPE When a `request_block` is used to send data, an error on the server side only gets reported as a `EPIPE`. excon doesn't read anything sent back from the server, which makes it hard to debug what went wrong. We now read the server response, if any, and show it in the exception. Closes #760 --- lib/excon/connection.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/excon/connection.rb b/lib/excon/connection.rb index 1e3f4400..fa327e48 100644 --- a/lib/excon/connection.rb +++ b/lib/excon/connection.rb @@ -190,6 +190,11 @@ def request_call(datum) case error when Excon::Errors::InvalidHeaderKey, Excon::Errors::InvalidHeaderValue, Excon::Errors::StubNotFound, Excon::Errors::Timeout raise(error) + when Errno::EPIPE + # Read whatever remains in the pipe to aid in debugging + response = socket.read + error = Excon::Error.new(response + error.message) + raise_socket_error(error) else raise_socket_error(error) end