1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 12:30:56 +01:00

Fail gracefully on bad API call when building commit mail

Summary:
Ref T8574. This could fail because the target is disabled (as here), or doesn't have access to the API, or the API request needs to be satisfied by a different host which isn't available.

In any of these cases, just show the failure and continue generating the mail. This field isn't important enough to block the mail, and many of these errors are permanent.

(I'll follow up on T8574 with some more permanent ideas to address this class of issue.)

Test Plan: Faked API call failure, generated mail, saw clean generation of mail with a failure message.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8574

Differential Revision: https://secure.phabricator.com/D13319
This commit is contained in:
epriestley 2015-06-16 16:06:42 -07:00
parent 42170ab151
commit bb7f2ea905

View file

@ -29,18 +29,25 @@ final class PhabricatorCommitBranchesField
'callsign' => $this->getObject()->getRepository()->getCallsign(), 'callsign' => $this->getObject()->getRepository()->getCallsign(),
); );
$branches_raw = id(new ConduitCall('diffusion.branchquery', $params)) try {
->setUser($this->getViewer()) $branches_raw = id(new ConduitCall('diffusion.branchquery', $params))
->execute(); ->setUser($this->getViewer())
->execute();
$branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches_raw); $branches = DiffusionRepositoryRef::loadAllFromDictionaries(
if (!$branches) { $branches_raw);
return; if (!$branches) {
return;
}
$branch_names = mpull($branches, 'getShortName');
sort($branch_names);
$branch_text = implode(', ', $branch_names);
} catch (Exception $ex) {
$branch_text = pht('<%s: %s>', get_class($ex), $ex->getMessage());
} }
$branch_names = mpull($branches, 'getShortName');
sort($branch_names);
$body->addTextSection(pht('BRANCHES'), implode(', ', $branch_names)); $body->addTextSection(pht('BRANCHES'), $branch_text);
} }
} }