feat(exceptions): add typed exception hierarchy with machine error codes#5
Merged
vitormattos merged 8 commits intomainfrom Mar 22, 2026
Merged
feat(exceptions): add typed exception hierarchy with machine error codes#5vitormattos merged 8 commits intomainfrom
vitormattos merged 8 commits intomainfrom
Conversation
Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: Vitor Mattos <vitor@php.rio>
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.
Summary
Completes Phase 1 of the nfse-php contract layer by introducing a typed
exception hierarchy with machine-readable error codes.
New types
NfseErrorCode— backed enum (string) with five machine error codes:NETWORK_FAILURE,INVALID_RESPONSE,ISSUANCE_REJECTED,CANCELLATION_REJECTED,QUERY_FAILEDGatewayException— base for 4xx/5xx gateway errors; carrieserrorCode,httpStatus, andupstreamPayload(raw decoded response body for diagnostics)NetworkException— connectivity failures and unparseable responsesIssuanceException extends GatewayException— gateway rejected an emitCancellationException extends GatewayException— gateway rejected a cancelQueryException extends GatewayException— gateway returned an error for a queryNfseClient changes
request()renamed tofetchAndDecode(): now returnsarray{int, array}(HTTP status + decoded body) instead of a bare decoded array
$http_response_header(set by PHP in localscope when using the HTTP wrapper)
emit/query/cancelcheck the status and throw the appropriate typedexception before delegating to
parseReceiptResponsedelete()return type changed fromvoidtoarray{int, array}so callerscan inspect the cancellation status
Validation
composer test:unit— 19/19 ✓ (6 new typed-exception tests)composer cs:fix— 0 files changedcomposer psalm— No errors found