Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/VCS/Adapter/Git/GitHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Exception;
use Utopia\Cache\Cache;
use Utopia\VCS\Adapter\Git;
use Utopia\VCS\Exception\RepositoryNotFound;

class GitHub extends Git
{
Expand Down Expand Up @@ -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
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 ?

}

return $response['body']['name'];
Expand Down
7 changes: 7 additions & 0 deletions src/VCS/Exception/RepositoryNotFound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Utopia\VCS\Exception;

class RepositoryNotFound extends \Exception
{
}
2 changes: 1 addition & 1 deletion tests/Detector/DetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testLanguageDetection(): void
['Dobiasd', 'FunctionalPlus', 'cpp'],
['anthonychu', 'azure-functions-deno-worker', 'deno'],
['mono', 'mono-basic', 'dotnet'],
['Meldiron', 'bun-function', 'bun'],
['vermakhushboo', 'bun-function', 'bun'],
['cytoscape', 'cytoscape.js', 'node']
];

Expand Down