1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

Catch more HTTP VCS errors and convert them into VCS repsonses

Summary:
Ref T13590. Currently, errors arising from cluster locking (like the "stuck write lock" exception) are not caught and converted into VCS responses on the HTTP VCS workflow.

Catch a broader range of exceptions and convert them into appropriate responses.

Test Plan:
  - Forced a "stuck write lock" exception, pushed to a Git repository over HTTP.
  - Before: generic fatal.
  - After: VCS-specific fatal with a useful message in the "X-Phabricator-Message" response header.

Maniphest Tasks: T13590

Differential Revision: https://secure.phabricator.com/D21525
This commit is contained in:
epriestley 2021-01-26 15:39:45 -08:00
parent 32c82a53de
commit da7d92dd0a

View file

@ -397,7 +397,25 @@ final class DiffusionServeController extends DiffusionController {
switch ($vcs_type) { switch ($vcs_type) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$caught = null;
try {
$result = $this->serveVCSRequest($repository, $viewer); $result = $this->serveVCSRequest($repository, $viewer);
} catch (Exception $ex) {
$caught = $ex;
} catch (Throwable $ex) {
$caught = $ex;
}
if ($caught) {
// We never expect an uncaught exception here, so dump it to the
// log. All routine errors should have been converted into Response
// objects by a lower layer.
phlog($caught);
$result = new PhabricatorVCSResponse(
500,
phutil_string_cast($caught->getMessage()));
}
break; break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$result = new PhabricatorVCSResponse( $result = new PhabricatorVCSResponse(