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

Commits on May 16, 2022

  1. Make exception API compatible with what Ruby expects

    Ruby expects that the first argument to Exception#initialize is a
    string (or nil), since that is what Kernel#raise uses.  Breaking that
    assumption is a very bad idea.
    
    This problem was introduced in 16be09a60c77bcf7ce10fa91cc3689c0d11b0f4bm.
    A backwards compatible approach would have added a response keyword
    argument.  Unfortunately, that ship has sailed, unless we want to break
    backwards compatibility again.
    
    Try to restore backwards compatibility and align with standard Ruby
    exception behavior by checking whether the first message to #initialize
    is an STMP::Response.  If so, use it as the response.  If not, treat it
    as the exception message.
    
    This prevents issues in code that does something like:
    
    ```ruby
      raise exception_class, exception_message
    ```
    
    Before this change, you'll get a NoMethodError later inside of
    SMTPError#message, with no indication of the actual problem.
    jeremyevans committed May 16, 2022
    1 Configuration menu
    Copy the full SHA
    3abed21 View commit details
    Browse the repository at this point in the history