Wrap PSR-18 transport failures in a TransportException - #18
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 1.x #18 +/- ##
============================================
+ Coverage 98.51% 98.58% +0.06%
- Complexity 148 152 +4
============================================
Files 24 25 +1
Lines 404 423 +19
============================================
+ Hits 398 417 +19
Misses 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Aug 17, 2026
QuickpayException's docblock promises that catch (QuickpayException) nets all SDK-thrown exceptions — but a DNS failure, refused connection or timeout came straight through as the HTTP client's ClientExceptionInterface, so consumers either missed them or had to know about PSR-18 to catch them. - New TransportException (final) extends RuntimeException implements QuickpayException AND Psr\Http\Client\ClientExceptionInterface — so an existing catch (ClientExceptionInterface) still matches. Exposes getRequest() (with the SDK headers applied), isNetworkError() (previous is a NetworkExceptionInterface) and the original as getPrevious(). Message: "The request could not be sent [METHOD sanitized-URL]: <original>". - Client::request() wraps; lastRequest is recorded and lastResponse reset to null for the failed attempt. - ClientInterface @throws updated; README error-handling section covers it. BC note: only code that catches Psr\Http\Client\NetworkExceptionInterface / RequestExceptionInterface SPECIFICALLY (rather than ClientExceptionInterface) would no longer match — check $e->getPrevious() instead. Refs #10 (finding 9).
loevgaard
force-pushed
the
dx/transport-exception
branch
from
August 17, 2026 09:48
b9efa0b to
771d2dd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of #10 (finding 9).
Why
QuickpayException's docblock promises thatcatch (QuickpayException $e)nets all SDK-thrown exceptions — but a DNS failure, refused connection or timeout came straight through as the HTTP client'sClientExceptionInterface, so consumers either missed them or had to know PSR-18 internals to catch them.What
TransportException(final, extends\RuntimeException) implements bothQuickpayExceptionandPsr\Http\Client\ClientExceptionInterface— so an existingcatch (ClientExceptionInterface $e)still matches. It exposesgetRequest()(with the SDK headers applied),isNetworkError()(previous is aNetworkExceptionInterface), and the original exception asgetPrevious(). Message:The request could not be sent [GET https://api.quickpay.net/payments]: connection refused(query string stripped, like the other exceptions).Client::request()wraps the PSR-18 exception;getLastRequest()records the attempt andgetLastResponse()is reset tonullfor it.ClientInterface@throwsupdated (TransportExceptioninstead ofClientExceptionInterface);QuickpayExceptiondocblock now true; README error-handling section covers it (with the retry-safety hint that pairs withfindByOrderId()from Add PaymentsEndpoint::findByOrderId() and typed list filters (PaymentsQuery) #12).BC note
Only code that catches
NetworkExceptionInterface/RequestExceptionInterfacespecifically (rather thanClientExceptionInterface) would no longer match — it should check$e->getPrevious()(orisNetworkError()) instead. Flagging so you can decide; I think fulfilling the documented "one catch nets everything" contract is worth it a week after 1.0.0.Tests: network vs request failures (a small in-test throwing PSR-18 client), message/URI sanitizing, last request/response bookkeeping,
catch (QuickpayException)netting it, and the hierarchy test covers both interfaces.