Skip to content

Commit

Permalink
Merge pull request #42 from jeremyevans/make-exception-api-compatible
Browse files Browse the repository at this point in the history
Make exception API compatible with what Ruby expects
  • Loading branch information
tmtm authored May 20, 2022
2 parents 39d23dc + 3abed21 commit 1d28fe4
Showing 1 changed file with 8 additions and 3 deletions.
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

0 comments on commit 1d28fe4

Please sign in to comment.