Skip to content

Conversation

@markovic-nikola
Copy link
Contributor

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

2024-12-23_18-00 (1)

@taylorotwell taylorotwell merged commit 8f5a17e into laravel:11.x Dec 23, 2024
40 checks passed
@jayanratna
Copy link
Contributor

Just wanted to mention that the statusCode is not returned for successful responses, it is only returned for error responses. This would mean that $result['statusCode'] != Response::HTTP_OK would return true as its not apart of the $result.

Tested this logic on https://github.com/resend/resend-laravel with its test suite.

markovic-nikola added a commit to markovic-nikola/framework that referenced this pull request Dec 23, 2024
@markovic-nikola
Copy link
Contributor Author

Hi @jayanratna,
Thanks for mentioning it, I have created another PR to address it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants