Skip to content

Commit

Permalink
Add specific exception if pad is not publicly available (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gared authored Oct 9, 2024
1 parent 33b130d commit 9b2d64d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/Exception/EtherpadServiceNotPublicException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);

namespace Gared\EtherScan\Exception;

use Exception;

class EtherpadServiceNotPublicException extends Exception
{
}
8 changes: 3 additions & 5 deletions src/Service/ScannerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Exception;
use Gared\EtherScan\Api\GithubApi;
use Gared\EtherScan\Exception\EtherpadServiceNotFoundException;
use Gared\EtherScan\Exception\EtherpadServiceNotPublicException;
use Gared\EtherScan\Model\VersionRange;
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;
Expand Down Expand Up @@ -189,9 +190,6 @@ private function scanAdmin(ScannerServiceCallbackInterface $callback): void
$this->getAdmin('user', 'changeme1', $callback);
}

/**
* @throws EtherpadServiceNotFoundException
*/
private function scanPad(ScannerServiceCallbackInterface $callback): void
{
$callback->onScanPadStart();
Expand Down Expand Up @@ -529,7 +527,7 @@ private function handleClientVarsResponse(
$data = $data[1];
$accessStatus = $data['accessStatus'] ?? null;
if ($accessStatus === 'deny') {
$callback->onScanPadException(new EtherpadServiceNotFoundException('Pads are not publicly accessible'));
$callback->onScanPadException(new EtherpadServiceNotPublicException('Pads are not publicly accessible'));
return;
}

Expand Down Expand Up @@ -582,7 +580,7 @@ private function doSocketWebsocket(
if ($result !== null && is_array($result->data)) {
$accessStatus = $result->data['accessStatus'] ?? null;
if ($accessStatus === 'deny') {
$callback->onScanPadException(new EtherpadServiceNotFoundException('Pads are not publicly accessible'));
$callback->onScanPadException(new EtherpadServiceNotPublicException('Pads are not publicly accessible'));
return;
}
$data = $result->data;
Expand Down

0 comments on commit 9b2d64d

Please sign in to comment.