-
Notifications
You must be signed in to change notification settings - Fork 27
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
Open
Ref34t
wants to merge
32
commits into
WordPress:trunk
Choose a base branch
from
Ref34t:feature/exception-hierarchy
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
32 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
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\Exception; | ||
|
||
use WordPress\AiClient\Exceptions\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\Exceptions\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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
JasonTheAdams marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
declare(strict_types=1); | ||
|
||
namespace WordPress\AiClient\Exceptions; | ||
|
||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace WordPress\AiClient\Providers\Http\Exception; | ||
|
||
use WordPress\AiClient\Common\Exception\RuntimeException; | ||
|
||
/** | ||
* Exception thrown for network-related errors. | ||
* | ||
* This includes HTTP transport errors, connection failures, | ||
* timeouts, and other network-related issues. | ||
* | ||
* @since n.e.x.t | ||
*/ | ||
class NetworkException extends RuntimeException | ||
JasonTheAdams marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
/** | ||
* Creates a NetworkException from a PSR-18 network exception. | ||
* | ||
* @since n.e.x.t | ||
* | ||
* @param string $uri The URI that was being requested. | ||
* @param \Throwable $networkException The PSR-18 network exception. | ||
* @return self | ||
*/ | ||
public static function fromPsr18NetworkException(string $uri, \Throwable $networkException): self | ||
{ | ||
$message = sprintf( | ||
'Network error occurred while sending request to %s: %s', | ||
$uri, | ||
$networkException->getMessage() | ||
); | ||
|
||
return new self($message, 0, $networkException); | ||
} | ||
} |
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.