Skip to content

Exceptions are never thrown when HTTP errors are encountered #42

Open
@CameronHall

Description

@CameronHall

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions