Skip to content

Commit

Permalink
chore: add URL service to the log when it fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Jul 16, 2024
1 parent f40200f commit 6206b45
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions includes/admin/helpers/class-rop-post-format-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1033,17 +1033,18 @@ public function build_image( $post_id ) {
*
* @return string
*/
public function get_short_url( $url, $short_url_service, $credentials = array() ) {
public function get_short_url( $url, $short_url_service, $credentials = array() ) {

try {
$shortner_factory = new Rop_Shortner_Factory();
$shortner_service = $shortner_factory->build( $short_url_service );
if ( ! empty( $credentials ) ) {
$shortner_service->set_credentials( $credentials );
}
$short_url = $shortner_service->shorten_url( $url );
} catch ( Exception $exception ) {
$log = new Rop_Logger();
$log->alert_error( 'Could NOT get short URL. Error: ' . $exception->getMessage() );
$log->alert_error( 'Could NOT get short URL for option <' . $short_url_service . '>. Error: ' . $exception->getMessage() );
$short_url = $url;
}

Expand Down

0 comments on commit 6206b45

Please sign in to comment.