diff --git a/src/applications/diffusion/controller/DiffusionServeController.php b/src/applications/diffusion/controller/DiffusionServeController.php --- a/src/applications/diffusion/controller/DiffusionServeController.php +++ b/src/applications/diffusion/controller/DiffusionServeController.php @@ -397,7 +397,25 @@ switch ($vcs_type) { case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: - $result = $this->serveVCSRequest($repository, $viewer); + $caught = null; + try { + $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; case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: $result = new PhabricatorVCSResponse(