Skip to content
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

Merged
merged 4 commits into from
Oct 13, 2023
Merged

Conversation

vermakhushboo
Copy link
Member

No description provided.


use Utopia\VCS\Exception;

class RepositoryNotFound extends Exception
Copy link
Contributor

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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new RepositoryNotFound("Repository not found");
throw new Exception("Repository not found");

You can use the VCS\Exception class directly

Copy link
Member Author

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.

Copy link
Contributor

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 ?

Copy link
Contributor

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

@christyjacob4 christyjacob4 merged commit be86617 into main Oct 13, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants