Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions src/wp-includes/ai-client/class-wp-ai-client-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ abstract class WP_AI_Client_Builder {
* WordPress error instance, if any error occurred during method calls.
*
* @since 7.0.0
* @since 7.2.0 Moved from `WP_AI_Client_Prompt_Builder` to the `WP_AI_Client_Builder` base class.
* @since 7.2.0 Moved from `WP_AI_Client_Prompt_Builder` to the `WP_AI_Client_Builder` base class,
* and changed visibility from private to protected.
* @var WP_Error|null
*/
private ?WP_Error $error = null;
protected ?WP_Error $error = null;

/**
* Constructor.
Expand Down Expand Up @@ -341,6 +342,28 @@ private function is_support_check_method( string $name ): bool {
return isset( $methods[ $name ] );
}

/**
* Checks whether the builder is in an error state.
*
* @since 7.2.0
*
* @return bool True if an error has occurred, false otherwise.
*/
public function has_error(): bool {
return null !== $this->error;
}

/**
* Retrieves the WP_Error instance if the builder is in an error state.
*
* @since 7.2.0
*
* @return WP_Error|null The error instance or null if no error has occurred.
*/
public function get_error(): ?WP_Error {
return $this->error;
}

/**
* Checks if a method name is a generating method (generate_*, convert_text_to_speech*).
*
Expand Down
Loading
Loading