Skip to content

Commit a1219cb

Browse files
authored
Merge pull request #1641 from ga-devfront/refacto/rename-exception
Rename UpgradeException to ProcessException
2 parents ca08741 + 7497775 commit a1219cb

28 files changed

Lines changed: 127 additions & 127 deletions

autoupgrade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public function trans($id, array $parameters = [], $domain = null, $locale = nul
191191
* @return string
192192
*
193193
* @throws \PrestaShop\Module\AutoUpgrade\Exceptions\DistributionApiException
194-
* @throws \PrestaShop\Module\AutoUpgrade\Exceptions\UpgradeException
194+
* @throws \PrestaShop\Module\AutoUpgrade\Exceptions\ProcessException
195195
* @throws \Twig\Error\LoaderError
196196
* @throws \Twig\Error\RuntimeError
197197
* @throws \Twig\Error\SyntaxError

classes/Commands/CheckNewVersionCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
use Exception;
2525
use PrestaShop\Module\AutoUpgrade\Exceptions\DistributionApiException;
26-
use PrestaShop\Module\AutoUpgrade\Exceptions\UpgradeException;
26+
use PrestaShop\Module\AutoUpgrade\Exceptions\ProcessException;
2727
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfiguration;
2828
use PrestaShop\Module\AutoUpgrade\Services\LocalVersionFilesService;
2929
use PrestaShop\Module\AutoUpgrade\Task\ExitCode;
@@ -49,7 +49,7 @@ protected function configure(): void
4949

5050
/**
5151
* @throws DistributionApiException
52-
* @throws UpgradeException
52+
* @throws ProcessException
5353
*/
5454
protected function execute(InputInterface $input, OutputInterface $output): ?int
5555
{

classes/Commands/CheckRequirementsCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
use Exception;
2525
use PrestaShop\Module\AutoUpgrade\Exceptions\DistributionApiException;
26-
use PrestaShop\Module\AutoUpgrade\Exceptions\UpgradeException;
26+
use PrestaShop\Module\AutoUpgrade\Exceptions\ProcessException;
2727
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfiguration;
2828
use PrestaShop\Module\AutoUpgrade\Task\ExitCode;
2929
use PrestaShop\Module\AutoUpgrade\UpgradeSelfCheck;
@@ -116,7 +116,7 @@ private function processRequirementErrors(): void
116116

117117
/**
118118
* @throws DistributionApiException
119-
* @throws UpgradeException
119+
* @throws ProcessException
120120
*/
121121
private function processRequirementWarnings(): void
122122
{

classes/Commands/UpdateCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
use InvalidArgumentException;
2626
use PrestaShop\Module\AutoUpgrade\DocumentationLinks;
2727
use PrestaShop\Module\AutoUpgrade\Exceptions\DistributionApiException;
28-
use PrestaShop\Module\AutoUpgrade\Exceptions\UpgradeException;
28+
use PrestaShop\Module\AutoUpgrade\Exceptions\ProcessException;
2929
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfiguration;
3030
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeFileNames;
3131
use PrestaShop\Module\AutoUpgrade\Task\ExitCode;
@@ -182,7 +182,7 @@ private function processConsoleInputConfiguration(InputInterface $input): void
182182

183183
/**
184184
* @throws DistributionApiException
185-
* @throws UpgradeException
185+
* @throws ProcessException
186186
* @throws Exception
187187
*/
188188
private function calculateUpdateTypeAfterConfigLoad(): void
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
use Exception;
2525

26-
class UpgradeException extends Exception
26+
class ProcessException extends Exception
2727
{
2828
const SEVERITY_ERROR = 1;
2929
const SEVERITY_WARNING = 2;
@@ -58,7 +58,7 @@ public function getSeverity(): int
5858
return $this->severity;
5959
}
6060

61-
public function addQuickInfo(string $quickInfo): UpgradeException
61+
public function addQuickInfo(string $quickInfo): ProcessException
6262
{
6363
$this->quickInfos[] = $quickInfo;
6464

@@ -70,14 +70,14 @@ public function addQuickInfo(string $quickInfo): UpgradeException
7070
*
7171
* @return $this
7272
*/
73-
public function setQuickInfos(array $quickInfos): UpgradeException
73+
public function setQuickInfos(array $quickInfos): ProcessException
7474
{
7575
$this->quickInfos = $quickInfos;
7676

7777
return $this;
7878
}
7979

80-
public function setSeverity(int $severity): UpgradeException
80+
public function setSeverity(int $severity): ProcessException
8181
{
8282
$this->severity = $severity;
8383

classes/Hooks/DisplayBackOfficeHeader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
use PrestaShop\Module\AutoUpgrade\DocumentationLinks;
2727
use PrestaShop\Module\AutoUpgrade\Environment;
2828
use PrestaShop\Module\AutoUpgrade\Exceptions\DistributionApiException;
29-
use PrestaShop\Module\AutoUpgrade\Exceptions\UpgradeException;
29+
use PrestaShop\Module\AutoUpgrade\Exceptions\ProcessException;
3030
use PrestaShop\Module\AutoUpgrade\Models\UpdateNotificationConfiguration;
3131
use PrestaShop\Module\AutoUpgrade\Services\UpdateNotificationService;
3232
use PrestaShop\Module\AutoUpgrade\Twig\PageSelectors;
@@ -115,7 +115,7 @@ public function __construct(UpgradeContainer $container, Request $request)
115115
* @return string
116116
*
117117
* @throws DistributionApiException
118-
* @throws UpgradeException
118+
* @throws ProcessException
119119
* @throws LoaderError
120120
* @throws RuntimeError
121121
* @throws SyntaxError
@@ -229,7 +229,7 @@ private function isEmployeeDefaultController(): bool
229229

230230
/**
231231
* @throws DistributionApiException
232-
* @throws UpgradeException
232+
* @throws ProcessException
233233
*/
234234
private function checkNewerVersion(): void
235235
{
@@ -255,7 +255,7 @@ private function updateIsAvailable(): bool
255255
/**
256256
* @return array<string, mixed>
257257
*
258-
* @throws UpgradeException
258+
* @throws ProcessException
259259
*/
260260
private function getParams(): array
261261
{

classes/Services/DownloadService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
namespace PrestaShop\Module\AutoUpgrade\Services;
2323

24-
use PrestaShop\Module\AutoUpgrade\Exceptions\UpgradeException;
24+
use PrestaShop\Module\AutoUpgrade\Exceptions\ProcessException;
2525
use PrestaShop\Module\AutoUpgrade\Log\Logger;
2626
use PrestaShop\Module\AutoUpgrade\UpgradeTools\Translator;
2727
use Symfony\Component\Filesystem\Exception\IOException;
@@ -44,7 +44,7 @@ public function __construct(Translator $translator, Logger $logger)
4444
}
4545

4646
/**
47-
* @throws UpgradeException
47+
* @throws ProcessException
4848
*/
4949
public function downloadWithRetry(string $downloadUrl, string $destinationPath, int $retryCount = self::MAX_DOWNLOAD_TRY, int $delayInSeconds = self::WAIT_BETWEEN_RETRY_IN_SECONDS): void
5050
{
@@ -66,7 +66,7 @@ public function downloadWithRetry(string $downloadUrl, string $destinationPath,
6666
}
6767
}
6868

69-
throw new UpgradeException($this->translator->trans('All download attempts have failed.'));
69+
throw new ProcessException($this->translator->trans('All download attempts have failed.'));
7070
}
7171

7272
public function download(string $downloadUrl, string $destinationPath): void

classes/Task/AbstractTask.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
use Exception;
2525
use PrestaShop\Module\AutoUpgrade\AjaxResponse;
2626
use PrestaShop\Module\AutoUpgrade\Analytics;
27-
use PrestaShop\Module\AutoUpgrade\Exceptions\UpgradeException;
27+
use PrestaShop\Module\AutoUpgrade\Exceptions\ProcessException;
2828
use PrestaShop\Module\AutoUpgrade\Log\Logger;
2929
use PrestaShop\Module\AutoUpgrade\Task\Runner\ChainedTasks;
3030
use PrestaShop\Module\AutoUpgrade\UpgradeContainer;
@@ -161,14 +161,14 @@ public function init(): void
161161

162162
abstract public function run(): int;
163163

164-
protected function handleException(UpgradeException $e): void
164+
protected function handleException(ProcessException $e): void
165165
{
166-
if ($e->getSeverity() === UpgradeException::SEVERITY_ERROR) {
166+
if ($e->getSeverity() === ProcessException::SEVERITY_ERROR) {
167167
$this->next = TaskName::TASK_ERROR;
168168
$this->setErrorFlag();
169169
$this->logger->error($e->getMessage());
170170
}
171-
if ($e->getSeverity() === UpgradeException::SEVERITY_WARNING) {
171+
if ($e->getSeverity() === ProcessException::SEVERITY_WARNING) {
172172
$this->logger->warning($e->getMessage());
173173
$this->container->getUpdateState()->setWarningDetected(true);
174174
}

classes/Task/Backup/BackupDatabase.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
use Exception;
2525
use PDO;
2626
use PrestaShop\Module\AutoUpgrade\Database\TableFilter;
27-
use PrestaShop\Module\AutoUpgrade\Exceptions\UpgradeException;
27+
use PrestaShop\Module\AutoUpgrade\Exceptions\ProcessException;
2828
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeFileNames;
2929
use PrestaShop\Module\AutoUpgrade\Progress\Backlog;
3030
use PrestaShop\Module\AutoUpgrade\Task\AbstractTask;
@@ -292,7 +292,7 @@ protected function warmUp(): int
292292
);
293293

294294
if (empty($listOfTables)) {
295-
throw (new UpgradeException($this->translator->trans('No valid tables were found to back up. Backup of database canceled.')))->setSeverity(UpgradeException::SEVERITY_ERROR);
295+
throw (new ProcessException($this->translator->trans('No valid tables were found to back up. Backup of database canceled.')))->setSeverity(ProcessException::SEVERITY_ERROR);
296296
}
297297

298298
$tablesToBackup = new Backlog($listOfTables, count($listOfTables));
@@ -337,7 +337,7 @@ private function openPartialBackupFile(string $backupfile)
337337
{
338338
// Figure out what compression is available and open the file
339339
if ($this->container->getFileSystem()->exists($backupfile)) {
340-
throw (new UpgradeException($this->translator->trans('Backup file %s already exists. Operation aborted.', [$backupfile])))->setSeverity(UpgradeException::SEVERITY_ERROR);
340+
throw (new ProcessException($this->translator->trans('Backup file %s already exists. Operation aborted.', [$backupfile])))->setSeverity(ProcessException::SEVERITY_ERROR);
341341
}
342342

343343
if (function_exists('bzopen')) {
@@ -351,7 +351,7 @@ private function openPartialBackupFile(string $backupfile)
351351
}
352352

353353
if ($fp === false) {
354-
throw (new UpgradeException($this->translator->trans('Unable to create backup database file %s.', [addslashes($backupfile)])))->setSeverity(UpgradeException::SEVERITY_ERROR);
354+
throw (new ProcessException($this->translator->trans('Unable to create backup database file %s.', [addslashes($backupfile)])))->setSeverity(ProcessException::SEVERITY_ERROR);
355355
}
356356

357357
return $fp;

classes/Task/Update/Download.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
use Exception;
2525
use PrestaShop\Module\AutoUpgrade\Exceptions\DistributionApiException;
26-
use PrestaShop\Module\AutoUpgrade\Exceptions\UpgradeException;
26+
use PrestaShop\Module\AutoUpgrade\Exceptions\ProcessException;
2727
use PrestaShop\Module\AutoUpgrade\Task\AbstractTask;
2828
use PrestaShop\Module\AutoUpgrade\Task\ExitCode;
2929
use PrestaShop\Module\AutoUpgrade\Task\TaskName;
@@ -83,7 +83,7 @@ public function run(): int
8383

8484
/**
8585
* @throws DistributionApiException
86-
* @throws UpgradeException
86+
* @throws ProcessException
8787
* @throws Exception
8888
*/
8989
public function downloadArchive(): void
@@ -102,7 +102,7 @@ public function downloadArchive(): void
102102
$this->logger->error($this->translator->trans('Download complete but MD5 sum does not match (%s).', [$md5file]));
103103
$this->next = TaskName::TASK_ERROR;
104104
}
105-
} catch (UpgradeException $e) {
105+
} catch (ProcessException $e) {
106106
$this->logger->error($this->translator->trans('The .zip archive could not be downloaded. The update is currently impossible. Please try again later.'));
107107
$this->next = TaskName::TASK_ERROR;
108108
}

0 commit comments

Comments
 (0)