diff --git a/src/applications/metamta/PhabricatorMetaMTAWorker.php b/src/applications/metamta/PhabricatorMetaMTAWorker.php --- a/src/applications/metamta/PhabricatorMetaMTAWorker.php +++ b/src/applications/metamta/PhabricatorMetaMTAWorker.php @@ -13,10 +13,6 @@ protected function doWork() { $message = $this->loadMessage(); - if (!$message) { - throw new PhabricatorWorkerPermanentFailureException( - pht('Unable to load message!')); - } if ($message->getStatus() != PhabricatorMailOutboundStatus::STATUS_QUEUE) { return; @@ -32,7 +28,18 @@ private function loadMessage() { $message_id = $this->getTaskData(); - return id(new PhabricatorMetaMTAMail())->load($message_id); + $message = id(new PhabricatorMetaMTAMail()) + ->load($message_id); + + if (!$message) { + throw new PhabricatorWorkerPermanentFailureException( + pht( + 'Unable to load mail message (with ID "%s") while preparing to '. + 'deliver it.', + $message_id)); + } + + return $message; } public function renderForDisplay(PhabricatorUser $viewer) { diff --git a/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php b/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php --- a/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php +++ b/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php @@ -23,11 +23,15 @@ $ex = $task->getExecutionException(); if ($ex) { if ($ex instanceof PhabricatorWorkerPermanentFailureException) { - $this->log( + // NOTE: Make sure these reach the daemon log, even when not + // running in "phd.verbose" mode. See T12803 for discussion. + $log_exception = new PhutilProxyException( pht( - 'Task %d was cancelled: %s', - $id, - $ex->getMessage())); + 'Task "%s" encountered a permanent failure and was '. + 'cancelled.', + $id), + $ex); + phlog($log_exception); } else if ($ex instanceof PhabricatorWorkerYieldException) { $this->log(pht('Task %s yielded.', $id)); } else {