Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make exception API compatible with what Ruby expects #42

Merged
merged 1 commit into from
May 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/net/smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ module SMTPError
attr_reader :response

def initialize(response, message: nil)
@response = response
@message = message
if response.is_a?(::Net::SMTP::Response)
@response = response
@message = message
else
@response = nil
@message = message || response
end
end

def message
Expand Down Expand Up @@ -643,7 +648,7 @@ def do_start(helo_domain, user, secret, authtype)
do_helo helo_domain
if ! tls? and (starttls_always? or (capable_starttls? and starttls_auto?))
unless capable_starttls?
raise SMTPUnsupportedCommand.new(nil, message: "STARTTLS is not supported on this server")
raise SMTPUnsupportedCommand, "STARTTLS is not supported on this server"
end
starttls
@socket = new_internet_message_io(tlsconnect(s, @ssl_context_starttls))
Expand Down