[11.x] Fix/Improve Resend transport response handling #54004
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose of this PR
This small PR improves the error messages displayed when the Resend API returns an HTTP status code other than
200
. The goal is to make errors easier to understand without requiring extensive debugging.Problem
For example, when the daily quota is reached, the application throws an exception that lacks clarity:
Symfony\Component\Mime\Header\Headers::addTextHeader(): Argument #2 ($value) must be of type string, null given, called in /home/nikola/Projects/project/vendor/symfony/mime/Header/Headers.php on line 154
Solution
With this PR, such cases are handled gracefully, and a clearer error message is provided. For instance, when the daily quota is reached, the error would now read:
Request to Resend API failed. Reason: You have reached your daily email sending quota.
Resend response codes