|
13 | 13 | use Carbon\Carbon; |
14 | 14 | use Carbon\CarbonInterface; |
15 | 15 | use Closure; |
| 16 | +use Exception; |
16 | 17 | use Illuminate\Contracts\Mail\Mailable; |
17 | 18 | use Illuminate\Database\Eloquent\Model; |
18 | 19 | use Illuminate\Support\Arr; |
19 | 20 | use Illuminate\Support\Facades\Validator; |
20 | 21 | use Illuminate\Support\Str; |
21 | 22 | use Opis\Closure\SerializableClosure; |
| 23 | +use Throwable; |
22 | 24 |
|
23 | 25 | /** |
24 | 26 | * Class MailatorSchedule. |
@@ -324,27 +326,33 @@ public function logs() |
324 | 326 |
|
325 | 327 | public function shouldSend(): bool |
326 | 328 | { |
327 | | - $this->load('logs'); |
328 | | - |
329 | | - return $this->configurationsPasses() && $this->whenPasses() && $this->eventsPasses(); |
| 329 | + try { |
| 330 | + $this->load('logs'); |
| 331 | + return $this->configurationsPasses() && $this->whenPasses() && $this->eventsPasses(); |
| 332 | + } catch (Exception|Throwable) { |
| 333 | + return false; |
| 334 | + } |
330 | 335 | } |
331 | 336 |
|
332 | 337 | public function execute(bool $now = false): void |
333 | 338 | { |
334 | 339 | $this->save(); |
335 | 340 |
|
336 | | - if ($this->hasCustomAction()) { |
337 | | - unserialize($this->action)->handle($this); |
| 341 | + try { |
| 342 | + if ($this->hasCustomAction()) { |
| 343 | + unserialize($this->action)->handle($this); |
338 | 344 |
|
339 | | - $this->markAsSent(); |
| 345 | + $this->markAsSent(); |
340 | 346 |
|
341 | | - static::garbageResolver()->handle($this); |
342 | | - } else { |
343 | | - if ($now) { |
344 | | - dispatch_sync(new SendMailJob($this)); |
| 347 | + static::garbageResolver()->handle($this); |
345 | 348 | } else { |
346 | | - dispatch(new SendMailJob($this)); |
| 349 | + if ($now) { |
| 350 | + dispatch_sync(new SendMailJob($this)); |
| 351 | + } else { |
| 352 | + dispatch(new SendMailJob($this)); |
| 353 | + } |
347 | 354 | } |
| 355 | + } catch (Exception|Throwable) { |
348 | 356 | } |
349 | 357 | } |
350 | 358 |
|
|
0 commit comments