Skip to content

Commit

Permalink
Improved errors handling for imap functions calls
Browse files Browse the repository at this point in the history
closes #207
  • Loading branch information
barbushin committed Nov 15, 2017
1 parent ece5c91 commit 13d6747
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/PhpImap/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -820,14 +820,15 @@ public function imap($methodShortName, $args = [], $prependConnectionAsFirstArg
imap_errors(); // flush errors
$result = @call_user_func_array("imap_$methodShortName", $args);

$errors = imap_errors();

if($errors) {
if($throwExceptionClass) {
throw new $throwExceptionClass("IMAP method imap_$methodShortName() failed with error: " . implode('. ', $errors));
}
else {
return false;
if(!$result) {
$errors = imap_errors();
if($errors) {
if($throwExceptionClass) {
throw new $throwExceptionClass("IMAP method imap_$methodShortName() failed with error: " . implode('. ', $errors));
}
else {
return false;
}
}
}

Expand Down

0 comments on commit 13d6747

Please sign in to comment.