Skip to content

Commit

Permalink
Merge pull request #249 from 10up/fix/243
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Jul 3, 2023
2 parents dd01cf7 + 85fe833 commit 92df624
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions includes/admin/post-transition.php
Expand Up @@ -138,9 +138,19 @@ function publish_tweet( $post_id, $force = false ) {
$account = $connected_accounts[ $account_id ] ?? [];
$username = $account['username'] ?? '';

$twitter_response = $publish->status_update( $tweet, $post, $account_id );

$response = validate_response( $twitter_response );
try {
$twitter_response = $publish->status_update( $tweet, $post, $account_id );

$response = validate_response( $twitter_response );
} catch ( \Exception $e ) {
$response = new \WP_Error(
'autoshare_for_twitter_failed',
esc_html__( 'Something went wrong, please try again.', 'autoshare-for-twitter' ),
array(
(object) array( 'message' => $e->getMessage() ),
)
);
}

if ( ! is_wp_error( $response ) ) {
update_autoshare_for_twitter_meta_from_response( $post->ID, $response, $username );
Expand Down

0 comments on commit 92df624

Please sign in to comment.