Skip to content

Commit

Permalink
Update exception classes to use RuntimeException instead of Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
salahhusa9 committed Feb 3, 2024
1 parent 9946e08 commit 705485c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Exceptions/GitFailedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Salahhusa9\Updater\Exceptions;

use Exception;
use RuntimeException;

class GitFailedException extends Exception
class GitFailedException extends RuntimeException
{
/**
* GitFailedException constructor.
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/GithubConfigException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Salahhusa9\Updater\Exceptions;

use Exception;
use RuntimeException;

class GithubConfigException extends Exception
class GithubConfigException extends RuntimeException
{
/**
* GithubConfigException constructor.
Expand Down
2 changes: 1 addition & 1 deletion src/Pipelines/GitPipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function handle($content, Closure $next)
call_user_func($content['output'], 'git checkout failed: '.$checkout);
}

return throw new \Exception('git checkout failed: '.$checkout);
return throw new \RuntimeException('git checkout failed: '.$checkout);
} else {
if (is_callable($content['output'])) {
call_user_func($content['output'], 'Checkout success');
Expand Down
4 changes: 2 additions & 2 deletions src/RepositorySource/GithubRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function getLatestVersion(): string
{
$this->checkConfig();

return isset($this->getLatestVersionData()['message']) ? throw new \Exception($this->getLatestVersionData()['message']) : $this->getLatestVersionData()['tag_name'];
return isset($this->getLatestVersionData()['message']) ? throw new \RuntimeException($this->getLatestVersionData()['message']) : $this->getLatestVersionData()['tag_name'];
}

/**
Expand Down Expand Up @@ -48,7 +48,7 @@ public function getVersions(): array
$versionsData = $this->getVersionsData();

if (isset($versionsData['message'])) {
throw new \Exception($versionsData['message']);
throw new \RuntimeException($versionsData['message']);
}

return $versionsData->map(function ($version) {
Expand Down
6 changes: 3 additions & 3 deletions src/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Updater
public function update(?callable $output = null): string
{
if (! is_null($output) and ! is_callable($output)) {
throw new \Exception('Output must be callable');
throw new \RuntimeException('Output must be callable');
}

$this->output = $output;
Expand Down Expand Up @@ -97,11 +97,11 @@ private function updateTo($version): string
if (is_array($pipelines) && count($pipelines) > 0) {
foreach ($pipelines as $pipeline) {
if (! is_subclass_of($pipeline, \Salahhusa9\Updater\Contracts\Pipeline::class)) {
throw new \Exception('Pipeline '.$pipeline.' is not implemented Pipeline contract:'.\Salahhusa9\Updater\Contracts\Pipeline::class);
throw new \RuntimeException('Pipeline '.$pipeline.' is not implemented Pipeline contract:'.\Salahhusa9\Updater\Contracts\Pipeline::class);
}
}
} else {
throw new \Exception('Pipelines is not array or empty');
throw new \RuntimeException('Pipelines is not array or empty');
}

$this->output('Start Updating to version '.$version);
Expand Down

0 comments on commit 705485c

Please sign in to comment.