saloon icon indicating copy to clipboard operation
saloon copied to clipboard

Adding hasRequestFailed() method to connector always throws an exception

Open bvtrfly opened this issue 6 months ago • 2 comments

I am currently integrating with an external API that returns a 200 OK status for every request, even when the request has actually failed. To handle this, I added a hasRequestFailed method to the connector.

However, I've noticed that if the logic inside hasRequestFailed evaluates to true, an exception is immediately thrown when the request is sent. As a result, the code never reaches the point where it checks whether the request has failed — the error is raised at the point of sending the request itself.

bvtrfly avatar Jul 15 '25 13:07 bvtrfly

I believe you just need to flip around the logic from true to false, if the hasRequestFailed returns true, then Saloon thinks the request has failed.

Sammyjo20 avatar Jul 15 '25 16:07 Sammyjo20

We added a temporary fix for issue by extending the shouldThrowRequestException() method and making it return false in both the connector and requests.

bvtrfly avatar Jul 15 '25 20:07 bvtrfly