From 66c47522035214b37ab65a41f93717ef02581133 Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Fri, 6 Jun 2025 11:52:49 +0200 Subject: [PATCH] Better logging in case of error while reposting reel --- .../Jobs/InstagramRepost/InstagramRepostJob.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/app/Browser/Jobs/InstagramRepost/InstagramRepostJob.php b/app/Browser/Jobs/InstagramRepost/InstagramRepostJob.php index 5400a1b..0e5cd80 100644 --- a/app/Browser/Jobs/InstagramRepost/InstagramRepostJob.php +++ b/app/Browser/Jobs/InstagramRepost/InstagramRepostJob.php @@ -175,13 +175,8 @@ class InstagramRepostJob extends BrowserJob implements ShouldBeUniqueUntilProces $reel = $infos[0]; $videoInfo = $infos[1]; - try { - // TODO : Avoid getting the reel from the db again, store it in the downloadedReels array - $repostedReelsCounter += $this->repostReel($browser, InstagramRepost::where('reel_id', $reel->reel_id)->first(), $videoInfo); - } catch (\Exception $e) { - Log::error("Failed to repost reel: {$videoInfo->getTitle()} - " . $e->getMessage()); - AllNotification::send(new JobDebugNotification($this->jobId, "Failed to repost reel: {$videoInfo->getTitle()} - " . $e->getMessage())); - } + // TODO : Avoid getting the reel from the db again, store it in the downloadedReels array + $repostedReelsCounter += $this->repostReel($browser, InstagramRepost::where('reel_id', $reel->reel_id)->first(), $videoInfo); } $this->jobRun->addArtifact(new JobArtifact([ @@ -346,17 +341,19 @@ class InstagramRepostJob extends BrowserJob implements ShouldBeUniqueUntilProces try { $browser->waitForText("Your post was shared", 60, true); $closeButton = $browser->driver->findElement(WebDriverBy::xpath('//div[./div/*[local-name() = "svg"][@aria-label="Close"]]')); - } catch (\Exception $e) { Log::error("Failed to repost reel: {$reel->reel_id} - " . $e->getMessage()); $browser->screenshot(JobDebugScreenshot::getFileName($this->jobId)); AllNotification::send(new JobDebugNotification($this->jobId, "Failed to repost reel: {$reel->reel_id} - " . $e->getMessage())); $closeButton->click(); + return false; } - - return false; + return true; // Reel reposted successfully, no error message found } } catch (\Exception $e) { + Log::error("Failed to repost reel: {$reel->reel_id} - " . $e->getMessage()); + $browser->screenshot(JobDebugScreenshot::getFileName($this->jobId)); + AllNotification::send(new JobDebugNotification($this->jobId, "Failed to repost reel: {$reel->reel_id} - " . $e->getMessage())); return false; } }