Skip to content

Conversation

@asadali214
Copy link
Collaborator

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.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause a breaking change)
  • Tests (adds or updates tests)
  • Documentation (adds or updates documentation)
  • Refactor (style improvements, performance improvements, code refactoring)
  • Revert (reverts a commit)
  • CI/Build (adds or updates a script, change in external dependencies)

Dependency Change

N/A

Breaking change

N/A

Testing

Unit tests are added in the PR to test out the new functionality

Checklist

  • My code follows the coding conventions
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added new unit tests

@asadali214 asadali214 self-assigned this Jan 22, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in ErrorType to 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.

@sonarqubecloud
Copy link

@asadali214 asadali214 merged commit a48a583 into master Jan 27, 2026
11 checks passed
@asadali214 asadali214 deleted the feat-error-type-mapping branch January 27, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants