feat(error-type-mapping): adds support to map the error types in the result property of ApiResponse#78
Conversation
…result property of ApiResponse
There was a problem hiding this comment.
Pull request overview
This PR introduces functionality to map error response bodies to their respective types when returning ApiResponse objects, enabling better error handling through type-safe error responses.
Changes:
- Added
mapErrorTypesInApiResponse()method to enable error type mapping in API responses - Introduced
getClassName()method inErrorTypeto expose the error class name - Refactored
ResponseError::getResult()to extract API response handling into a separate method
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Mocking/Other/MockException4.php | Adds new mock exception class for testing error type mapping |
| tests/ApiCallTest.php | Adds comprehensive test coverage for the new error type mapping functionality |
| src/Response/Types/ErrorType.php | Exposes error class name through new getter method and updates documentation |
| src/Response/ResponseHandler.php | Provides public API method to enable error type mapping in responses |
| src/Response/ResponseError.php | Implements core logic for mapping error types and refactors response handling |
| src/Response/Context.php | Adds method to create API responses with mapped error types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…at-error-type-mapping
|
|
This PR was automatically closed because some checks failed. |
|
This PR was automatically closed because some checks failed. |
|
This PR was automatically closed because some checks failed. |



What
This PR adds a new functionality to mapErrorTypes while returning ApiResponse, along with unit tests.
Why
This implementation enabled better error handling by mapping error response bodies to their respective types.
Type of change
Select multiple if applicable.
Dependency Change
N/A
Breaking change
N/A
Testing
Unit tests are added in the PR to test out the new functionality
Checklist