| @@ -15,8 +15,9 @@ | ||
| 15 | 15 | use Yoast\WP\SEO\Actions\Indexing\Indexing_Prepare_Action; |
| 16 | 16 | use Yoast\WP\SEO\Actions\Indexing\Post_Link_Indexing_Action; |
| 17 | 17 | use Yoast\WP\SEO\Actions\Indexing\Term_Link_Indexing_Action; |
| 18 | 18 | use Yoast\WP\SEO\Conditionals\No_Conditionals; |
| 19 | +use Yoast\WP\SEO\Exceptions\Indexable\Indexing_Failed_Exception; | |
| 19 | 20 | use Yoast\WP\SEO\Helpers\Indexing_Helper; |
| 20 | 21 | use Yoast\WP\SEO\Helpers\Options_Helper; |
| 21 | 22 | use Yoast\WP\SEO\Main; |
| 22 | 23 | |
| @@ -417,8 +418,22 @@ | ||
| 417 | 418 | */ |
| 418 | 419 | protected function run_indexation_action( Indexation_Action_Interface $indexation_action, $url ) { |
| 419 | 420 | try { |
| 420 | 421 | return parent::run_indexation_action( $indexation_action, $url ); |
| 422 | + } catch ( Indexing_Failed_Exception $exception ) { | |
| 423 | + $this->indexing_helper->indexing_failed(); | |
| 424 | + | |
| 425 | + $previous = $exception->getPrevious(); | |
| 426 | + | |
| 427 | + return new WP_Error( | |
| 428 | + 'wpseo_error_indexing', | |
| 429 | + $exception->getMessage(), | |
| 430 | + [ | |
| 431 | + 'stackTrace' => ( $previous !== null ) ? $previous->getTraceAsString() : $exception->getTraceAsString(), | |
| 432 | + 'object_id' => $exception->get_object_id(), | |
| 433 | + 'object_type' => $exception->get_object_type(), | |
| 434 | + ], | |
| 435 | + ); | |
| 421 | 436 | } catch ( Exception $exception ) { |
| 422 | 437 | $this->indexing_helper->indexing_failed(); |
| 423 | 438 | |
| 424 | 439 | return new WP_Error( |