generated from Nodarx/template
refactor: unify command complition checking
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -129,9 +129,12 @@ final class ProtocolReader
|
||||
if (str_starts_with($trimmed, $tag . ' ')) {
|
||||
$parts = preg_split('/\s+/', $trimmed, 3) ?: [];
|
||||
$status = strtoupper($parts[1] ?? '');
|
||||
if ($status === 'NO' || $status === 'BAD') {
|
||||
throw new ImapException(sprintf('FETCH command failed: %s', $trimmed));
|
||||
}
|
||||
CompletionChecker::assertSuccess('FETCH', new TaggedResponse(
|
||||
$tag,
|
||||
$status,
|
||||
$parts[2] ?? '',
|
||||
$trimmed,
|
||||
));
|
||||
return null; // Tagged OK without ever finding a literal → UID not found
|
||||
}
|
||||
|
||||
@@ -145,9 +148,7 @@ final class ProtocolReader
|
||||
$response = $this->readResponse();
|
||||
|
||||
if ($response instanceof TaggedResponse && $response->tag() === $tag) {
|
||||
if (!$response->isOk()) {
|
||||
throw new ImapException(sprintf('FETCH failed: %s', $response->text()));
|
||||
}
|
||||
CompletionChecker::assertSuccess('FETCH', $response);
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user