Skip to content

Conversation

@vermakhushboo
Copy link
Contributor

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?


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
Contributor 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

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.

4 participants