- 
                Notifications
    You must be signed in to change notification settings 
- Fork 34
Implement Exception Hierarchy For Better Error Handling #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            felixarntz
  merged 41 commits into
  WordPress:trunk
from
Ref34t:feature/exception-hierarchy
  
      
      
   
  Sep 30, 2025 
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            41 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      19b0b50
              
                Implement simplified exception hierarchy for better error handling
              
              
                 f1b23d3
              
                Fix code style violations
              
              
                 a22c94e
              
                Implement exception hierarchy reorganization with static factory methods
              
              
                 98a84cf
              
                Fix code style violations in exception classes
              
              
                 28ce137
              
                Fix line length violations in exception factory methods
              
              
                 227498b
              
                Fix function declaration brace placement
              
              
                 eb9686d
              
                Update @since tags from 0.2.0 to n.e.x.t
              
              
                 f158e71
              
                Update core files to use custom exception classes - ProviderRegistry …
              
              
                 9eac85b
              
                Update HTTP and File DTOs to use custom exceptions - Files/DTO/File.p…
              
              
                 1f2fc0e
              
                Implement usage-driven exception hierarchy - Add ResponseException::f…
              
              
                 c1aede5
              
                Add exception handling requirements to coding standards
              
              
                 f901fce
              
                Implement usage-driven exception hierarchy with custom classes
              
              
                 048d889
              
                Fix File exception handling to use specific MimeType exceptions
              
              
                 499b5ab
              
                Complete exception hierarchy implementation across entire codebase
              
              
                 469f46e
              
                Fix accidentally removed try-catch for unrecognized file extensions
              
              
                 c0d3b74
              
                Update test to expect correct fallback error message for unknown exte…
              
              
                 04e767f
              
                Implement PSR-18 exception interfaces for HTTP client compliance
              
              
                 d2f5d62
              
                Generalize exception handling guidelines in AGENTS.md
              
              
                 9330edd
              
                Fix code style violations in HTTP exception classes
              
              
                 34fec79
              
                Merge remote-tracking branch 'origin/trunk' into feature/exception-hi…
              
              
                 5fe7df9
              
                Restore missing ModelRequirements methods from trunk
              
              
                 23ceb28
              
                Fix code style: add missing newline at end of file
              
              
                 a6bbaf2
              
                Implement exception hierarchy improvements
              
              
                 7c742aa
              
                Update Anthropic and Google ModelMetadataDirectory to use ResponseExc…
              
              
                 4a69461
              
                Implement ClientException for 4xx responses in ResponseUtil
              
              
                 8ab52c3
              
                Implement complete exception hierarchy with ClientException and Serve…
              
              
                 beb17e1
              
                Update tests to expect new exception hierarchy
              
              
                 44c8a4f
              
                Enhance ResponseException with semantic factory methods for parsing e…
              
              
                 4314134
              
                Build centralized error message extraction utility
              
              
                 0f18425
              
                Implement semantic exception hierarchy with proper inheritance patterns
              
              
                 2867cbc
              
                Update exception classes to use centralized error extraction and Requ…
              
              
                 e16fba4
              
                Update exception tests for new hierarchy structure
              
              
                 5e765f8
              
                Remove special 400 handling from ResponseUtil
              
              
                 01bafd9
              
                Rename fromClientError to fromClientErrorResponse and fix test expect…
              
              
                 7bbaadd
              
                Remove unnecessary ClientException static methods and add status mapping
              
              
                 4e5529c
              
                Remove unused RequestInterface import from ClientException
              
              
                 4cc060b
              
                Remove ResponseException::fromBadResponse and enhance ServerException…
              
              
                 436549f
              
                Complete exception hierarchy with indexed field names and simplified …
              
              
                 8cde241
              
                Fix test expectations for new exception hierarchy with indexed field …
              
              
                 8dd8719
              
                Merge branch 'trunk' into feature/exception-hierarchy
              
              
                felixarntz ef9a3bb
              
                Enhance HTTP request exception message format.
              
              
                felixarntz File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
|  | ||
| declare(strict_types=1); | ||
|  | ||
| namespace WordPress\AiClient\Common\Contracts; | ||
|  | ||
| use Throwable; | ||
|  | ||
| /** | ||
| * Base interface for all AI Client exceptions. | ||
| * | ||
| * This interface allows callers to catch all AI Client specific exceptions | ||
| * with a single catch statement. | ||
| * | ||
| * @since n.e.x.t | ||
| */ | ||
| interface AiClientExceptionInterface extends Throwable | ||
| { | ||
| } | 
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
|  | ||
| declare(strict_types=1); | ||
|  | ||
| namespace WordPress\AiClient\Common\Exception; | ||
|  | ||
| use WordPress\AiClient\Common\Contracts\AiClientExceptionInterface; | ||
|  | ||
| /** | ||
| * Exception thrown when an invalid argument is provided. | ||
| * | ||
| * This extends PHP's built-in InvalidArgumentException while implementing | ||
| * the AI Client exception interface for consistent catch handling. | ||
| * | ||
| * @since n.e.x.t | ||
| */ | ||
| class InvalidArgumentException extends \InvalidArgumentException implements AiClientExceptionInterface | ||
| { | ||
| } | 
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
|  | ||
| declare(strict_types=1); | ||
|  | ||
| namespace WordPress\AiClient\Common\Exception; | ||
|  | ||
| use WordPress\AiClient\Common\Contracts\AiClientExceptionInterface; | ||
|  | ||
| /** | ||
| * Exception thrown for runtime errors. | ||
| * | ||
| * This extends PHP's built-in RuntimeException while implementing | ||
| * the AI Client exception interface for consistent catch handling. | ||
| * | ||
| * @since n.e.x.t | ||
| */ | ||
| class RuntimeException extends \RuntimeException implements AiClientExceptionInterface | ||
| { | ||
| } | 
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  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.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.