Skip to content

Commit 0aa7f9f

Browse files
committed
Catch ItemNotFoundExceptions
1 parent 9f2cece commit 0aa7f9f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Folder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use DirectoryTree\ImapEngine\Exceptions\Exception;
99
use DirectoryTree\ImapEngine\Exceptions\ImapCapabilityException;
1010
use Illuminate\Contracts\Support\Arrayable;
11+
use Illuminate\Support\ItemNotFoundException;
1112
use JsonSerializable;
1213

1314
class Folder implements Arrayable, JsonSerializable
@@ -115,8 +116,12 @@ function (int $msgn) use ($callback, $fetch) {
115116

116117
try {
117118
$message = $fetch($msgn);
119+
} catch (ItemNotFoundException) {
120+
// The message wasn't found. We will skip
121+
// it and continue awaiting new messages.
122+
return;
118123
} catch (Exception) {
119-
// If fetching the message fails, we'll attempt
124+
// Something else happened. We will attempt
120125
// reconnecting and re-fetching the message.
121126
$this->mailbox->reconnect();
122127

0 commit comments

Comments
 (0)