Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
3abed21
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this fix. This had given me a headache until I used this workaround in ApplicationMailer:
After updating to net-smtp 0.3.2, error handling works without this workaround.