Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes "TypeError" for all http 404 responses
Prior to this PR, any `404` response from mailgun would cause a `TypeError: exception class/object expected` to be thrown from the mailgun gem. What was happening is that the `#submit` method in `Mailgun::Base` would translate any `ClientError` to a `Mailgun::Error` (which does not inherit from `Exception`, and thus is not re-raisable) and then either re-raise that `Mailgun::Error`'s `#handle` or the error itself, based on whether `handle` returned an instance of `Mailgun::ErrorBase` or not. The slightly confusing thing here is that re-raising the `Mailgun::Error` class would always cause a `TypeError: exception class/object expected` exception, so that code path is never desired. There is either a bug in the inheritance of `Mailgun::Error`, and it **should** inherit from `Exception` (or, preferably, `StandardError`), which would allow it to be thrown directly, or we should remove the code path that throws this unthrowable class. Since `Mailgun::NotFound` was the only error class that seemed to take advantage of this option, and that in the case of a 404 response a `Mailgun::NotFound` exception seems a better error to throw, I propose in this PR to remove the option alltogether, and always throw the result of `Mailgun::Error#handle`.
- Loading branch information