@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Throw a more tailored exception after failing to resolve a ref

Summary: Ref T2683. Throw a more tailored exception to allow callers to distinguish between bad refs (which are expected, if users try to visit garbage branches) and other types of errors.

Test Plan: Tried to view branch "alksndfklansdf". Viewed branch "master".

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2683

Differential Revision: https://secure.phabricator.com/D9094

+25 -9
+2
src/__phutil_library_map__.php
··· 530 530 'DiffusionPushLogListController' => 'applications/diffusion/controller/DiffusionPushLogListController.php', 531 531 'DiffusionQuery' => 'applications/diffusion/query/DiffusionQuery.php', 532 532 'DiffusionRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionRawDiffQuery.php', 533 + 'DiffusionRefNotFoundException' => 'applications/diffusion/exception/DiffusionRefNotFoundException.php', 533 534 'DiffusionRenameHistoryQuery' => 'applications/diffusion/query/DiffusionRenameHistoryQuery.php', 534 535 'DiffusionRepositoryController' => 'applications/diffusion/controller/DiffusionRepositoryController.php', 535 536 'DiffusionRepositoryCreateController' => 'applications/diffusion/controller/DiffusionRepositoryCreateController.php', ··· 3172 3173 ), 3173 3174 'DiffusionQuery' => 'PhabricatorQuery', 3174 3175 'DiffusionRawDiffQuery' => 'DiffusionQuery', 3176 + 'DiffusionRefNotFoundException' => 'Exception', 3175 3177 'DiffusionRepositoryController' => 'DiffusionController', 3176 3178 'DiffusionRepositoryCreateController' => 'DiffusionRepositoryEditController', 3177 3179 'DiffusionRepositoryDefaultController' => 'DiffusionController',
+16
src/applications/diffusion/exception/DiffusionRefNotFoundException.php
··· 1 + <?php 2 + 3 + final class DiffusionRefNotFoundException extends Exception { 4 + 5 + private $ref; 6 + 7 + public function setRef($ref) { 8 + $this->ref = $ref; 9 + return $this; 10 + } 11 + 12 + public function getRef() { 13 + return $this->ref; 14 + } 15 + 16 + }
+7 -9
src/applications/diffusion/request/DiffusionRequest.php
··· 4 4 * Contains logic to parse Diffusion requests, which have a complicated URI 5 5 * structure. 6 6 * 7 - * 8 7 * @task new Creating Requests 9 8 * @task uri Managing Diffusion URIs 10 - * 11 - * @group diffusion 12 9 */ 13 10 abstract class DiffusionRequest { 14 11 ··· 644 641 } 645 642 646 643 if ($this->getSupportsBranches()) { 647 - $branch = $this->getResolvableBranchName($this->getBranch()); 644 + $ref = $this->getResolvableBranchName($this->getBranch()); 648 645 } else { 649 - $branch = 'HEAD'; 646 + $ref = 'HEAD'; 650 647 } 651 648 652 - $results = $this->resolveRefs(array($branch)); 649 + $results = $this->resolveRefs(array($ref)); 653 650 654 - $matches = idx($results, $branch, array()); 651 + $matches = idx($results, $ref, array()); 655 652 if (count($matches) !== 1) { 656 - throw new Exception( 657 - pht('Ref "%s" is ambiguous or does not exist.', $branch)); 653 + $message = pht('Ref "%s" is ambiguous or does not exist.', $ref); 654 + throw id(new DiffusionRefNotFoundException($message)) 655 + ->setRef($ref); 658 656 } 659 657 660 658 $this->stableCommit = idx(head($matches), 'identifier');