diff --git a/CHANGELOG.md b/CHANGELOG.md index bbdc636..e509906 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- A `#[Schedule]` method whose event could not be placed in WordPress cron was logged without the reason. The log entry now carries the exception, under the `exception` key of its context, as the other discoveries do. + ## [1.0.5] - 2026-12-03 ### Fixed diff --git a/src/Infrastructure/Services/ScheduleDiscovery.php b/src/Infrastructure/Services/ScheduleDiscovery.php index c0b65f9..f1d08e4 100644 --- a/src/Infrastructure/Services/ScheduleDiscovery.php +++ b/src/Infrastructure/Services/ScheduleDiscovery.php @@ -198,8 +198,8 @@ private function placeWordPressCron(string $hookName, string $interval, array $a { try { $this->engine()->schedule(new Event($hookName, $this->engine()->now(), $interval, $args)); - } catch (ScheduleException) { - $this->logger?->error('Failed to schedule WordPress cron event for hook: '.$hookName); + } catch (ScheduleException $scheduleException) { + $this->logger?->error('Failed to schedule WordPress cron event for hook: '.$hookName, ['exception' => $scheduleException]); } } diff --git a/tests/Unit/ScheduleSurfaceTest.php b/tests/Unit/ScheduleSurfaceTest.php index bde8436..04494ba 100644 --- a/tests/Unit/ScheduleSurfaceTest.php +++ b/tests/Unit/ScheduleSurfaceTest.php @@ -218,7 +218,10 @@ public function events(): array } }; $this->engine->useDriver($refusing); - $this->logger->shouldReceive('error')->once()->with('Failed to schedule WordPress cron event for hook: surface_plain'); + $this->logger->shouldReceive('error')->once()->with( + 'Failed to schedule WordPress cron event for hook: surface_plain', + Mockery::on(fn (array $context): bool => $context['exception'] instanceof ScheduleException && $context['exception']->getMessage() === 'refused'), + ); ($this->discover)(PlainSurfaceJobs::class)->apply(); });