-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw exception if repository not found #8
Conversation
|
||
use Utopia\VCS\Exception; | ||
|
||
class RepositoryNotFound extends Exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a new class here?
@@ -143,7 +144,7 @@ public function getRepositoryName(string $repositoryId): string | |||
$response = $this->call(self::METHOD_GET, $url, ['Authorization' => "Bearer $this->accessToken"]); | |||
|
|||
if (!isset($response['body']['name'])) { | |||
throw new Exception("Repository name not found"); | |||
throw new RepositoryNotFound("Repository not found"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new RepositoryNotFound("Repository not found"); | |
throw new Exception("Repository not found"); |
You can use the VCS\Exception class directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it this way so that in Appwrite I can do try/catch
, but only catch RepositoryNotFound
exception and throw exception accordingly there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. In that case, can you override the default Exception class ? class RepositoryNotFound extends \Exception
?
src/VCS/Exception.php
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so this file is not required unless you plan on specifically catching the Utopia\VCS\Exception
If you do plan to catch Utopia\VCS\Exception
specifically then it makes sense to keep this class and extend the RepositoryNotFound exception from Utopia\VCS\Exception
But if you are going to use it, then you don't need this file anymore
No description provided.