|
14 | 14 | use Binarcode\LaravelMailator\Constraints\SendScheduleConstraint; |
15 | 15 | use Binarcode\LaravelMailator\Constraints\WeeklyConstraint; |
16 | 16 | use Binarcode\LaravelMailator\Models\MailatorSchedule; |
| 17 | +use Throwable; |
17 | 18 |
|
18 | 19 | /** |
19 | 20 | * Trait ConstraintsResolver |
@@ -53,22 +54,34 @@ public function eventsPasses(): bool |
53 | 54 |
|
54 | 55 | public function constraintsDescriptions(): array |
55 | 56 | { |
56 | | - return collect($this->constraints) |
57 | | - ->map(fn (string $event) => unserialize($event)) |
58 | | - ->filter(fn ($event) => is_subclass_of($event, Descriptionable::class)) |
59 | | - ->reduce(function ($base, Descriptionable $descriable) { |
60 | | - return array_merge($base, $descriable::conditions()); |
61 | | - }, []); |
| 57 | + try { |
| 58 | + return collect($this->constraints) |
| 59 | + ->map(fn(string $event) => unserialize($event)) |
| 60 | + ->filter(fn($event) => is_subclass_of($event, Descriptionable::class)) |
| 61 | + ->reduce(function ($base, Descriptionable $descriable) { |
| 62 | + return array_merge($base, $descriable::conditions()); |
| 63 | + }, []); |
| 64 | + } catch (Throwable $e) { |
| 65 | + $this->markAsFailed($e->getMessage()); |
| 66 | + |
| 67 | + return []; |
| 68 | + } |
62 | 69 | } |
63 | 70 |
|
64 | 71 | public function constraintsNotSatisfiedDescriptions(): array |
65 | 72 | { |
66 | | - return collect($this->constraints) |
67 | | - ->map(fn (string $event) => unserialize($event)) |
68 | | - ->filter(fn ($event) => is_subclass_of($event, Descriptionable::class)) |
69 | | - ->filter(fn ($event) => ! $event->canSend($this, $this->logs)) |
70 | | - ->reduce(function ($base, Descriptionable $descriable) { |
71 | | - return array_merge($base, $descriable::conditions()); |
72 | | - }, []); |
| 73 | + try { |
| 74 | + return collect($this->constraints) |
| 75 | + ->map(fn(string $event) => unserialize($event)) |
| 76 | + ->filter(fn($event) => is_subclass_of($event, Descriptionable::class)) |
| 77 | + ->filter(fn($event) => !$event->canSend($this, $this->logs)) |
| 78 | + ->reduce(function ($base, Descriptionable $descriable) { |
| 79 | + return array_merge($base, $descriable::conditions()); |
| 80 | + }, []); |
| 81 | + } catch (Throwable $e) { |
| 82 | + $this->markAsFailed($e->getMessage()); |
| 83 | + |
| 84 | + return []; |
| 85 | + } |
73 | 86 | } |
74 | 87 | } |
0 commit comments