Skip to content

Commit

Permalink
Adds EOFError raise for when a session is dead
Browse files Browse the repository at this point in the history
  • Loading branch information
cgranleese-r7 committed Mar 20, 2024
1 parent 0611a3e commit aa9ed6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/ruby_smb/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,9 @@ def recv_packet(encrypt: false)
raw_response = dispatcher.recv_packet
rescue RubySMB::Error::CommunicationError => e
if encrypt
raise RubySMB::Error::EncryptionError, "Communication error with the "\
"remote host: #{e.message}. The server supports encryption but was "\
"not able to handle the encrypted request."
raise e, "Communication error with the "\
"remote host: #{e.message}. The server supports encryption and this error "\
"may have been caused by encryption issues, but not always."
else
raise e
end
Expand Down
5 changes: 2 additions & 3 deletions spec/lib/ruby_smb/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,9 @@
it 'raises an EncryptionError exception if an error occurs while receiving the response' do
allow(dispatcher).to receive(:recv_packet).and_raise(RubySMB::Error::CommunicationError)
expect { client.recv_packet(encrypt: true) }.to raise_error(
RubySMB::Error::EncryptionError,
RubySMB::Error::CommunicationError,
'Communication error with the remote host: RubySMB::Error::CommunicationError. '\
'The server supports encryption but was not able to handle the encrypted request.'
'The server supports encryption and this error may have been caused by encryption issues, but not always.'
)
end

Expand Down Expand Up @@ -2853,4 +2853,3 @@
end
end
end

0 comments on commit aa9ed6e

Please sign in to comment.