Skip to content

Exceptions are never thrown when HTTP errors are encountered #42

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

Open
CameronHall opened this issue May 16, 2025 · 0 comments
Open

Exceptions are never thrown when HTTP errors are encountered #42

CameronHall opened this issue May 16, 2025 · 0 comments

Comments

@CameronHall
Copy link

CameronHall commented May 16, 2025

Hi team,

I was integrating the SDK and was glad to see support for granular response code handling. However, it appears this isn’t actually used due to the call to ->returnApiResponse():

->throwErrorOn(
'422',
ErrorType::init(
'The request failed because it is semantically incorrect or failed business validation.',
ErrorException::class
)
)
->throwErrorOn('500', ErrorType::init('The request failed because an internal server error occurred.'))
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
->type(CapturedPayment::class)
->returnApiResponse();

This forces the implementing app to manually check isSuccessful() and handle errors without context, which can be cumbersome.

I understand that removing ->returnApiResponse() would be a breaking change, but doing so would also unlock better type safety and IDE support by allowing response models to be proper return types.

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

No branches or pull requests

1 participant