From bc7dbe427da37bbe313fabe83c10b00869179623 Mon Sep 17 00:00:00 2001 From: Oskar Eichler Date: Thu, 27 Aug 2026 23:55:02 +0300 Subject: [PATCH 1/2] Initialize SMTP exception messages through the superclass --- lib/net/smtp.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb index cca06e6..52db64e 100644 --- a/lib/net/smtp.rb +++ b/lib/net/smtp.rb @@ -33,16 +33,12 @@ module SMTPError def initialize(response, message: nil) if response.is_a?(::Net::SMTP::Response) @response = response - @message = message + super(message || response.message) else @response = nil - @message = message || response + super(message || response) end end - - def message - @message || response.message - end end # Represents an SMTP authentication error. From 781981ccf04adea6cf99f61c149f98e84a854266 Mon Sep 17 00:00:00 2001 From: Oskar Eichler <62393985+OskarEichler@users.noreply.github.com> Date: Fri, 28 Aug 2026 15:24:22 +0300 Subject: [PATCH 2/2] Add regression coverage for initialize smtp exception messages through the superclass --- test/net/smtp/test_response.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/net/smtp/test_response.rb b/test/net/smtp/test_response.rb index 3cf909a..6315db9 100644 --- a/test/net/smtp/test_response.rb +++ b/test/net/smtp/test_response.rb @@ -95,6 +95,14 @@ def test_default_exception res = Response.parse("250 omg fatal error") assert_equal Net::SMTPUnknownError, res.exception_class end + + def test_smtp_exception_uses_standard_exception_message + error = Net::SMTPFatalError.new("original") + replacement = error.exception("replacement") + + assert_equal "original", error.to_s + assert_equal "replacement", replacement.message + end end end end