Skip to content

Commit 59b475e

Browse files
committed
Use DbUpgradeException instead of a generic RuntimeException
1 parent 998a63b commit 59b475e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/Console/DbUpgradeCommand.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
use Exception;
66
use Exolnet\DbUpgrade\Exceptions\PreConditionNotMetException;
7+
use Exolnet\DbUpgrade\Exceptions\DbUpgradeException;
78
use Illuminate\Console\Command;
89
use Illuminate\Console\ConfirmableTrait;
910
use Illuminate\Filesystem\Filesystem;
1011
use Illuminate\Support\Facades\Artisan;
1112
use Illuminate\Support\Facades\DB;
1213
use Illuminate\Support\Facades\Schema;
13-
use RuntimeException;
1414
use Symfony\Component\Process\ExecutableFinder;
1515
use Symfony\Component\Process\Process;
1616

@@ -146,7 +146,7 @@ protected function checkPreConditions(): void
146146
}
147147

148148
if (!$this->option('force') && !$this->confirm('Do you have a backup of your database?')) {
149-
throw new RuntimeException('You need to have a backup to perform the upgrade.');
149+
throw new DbUpgradeException('You need to have a backup to perform the upgrade.');
150150
}
151151

152152
$this->commandMysqlDump = $this->findExecutable('mysqldump');
@@ -183,7 +183,7 @@ protected function backupDatabase(): void
183183
$export = Process::fromShellCommandline($command);
184184

185185
if ($export->run() !== 0) {
186-
throw new RuntimeException(
186+
throw new DbUpgradeException(
187187
'Could not create a backup of the database.' . PHP_EOL .
188188
$export->getErrorOutput()
189189
);
@@ -192,7 +192,7 @@ protected function backupDatabase(): void
192192
// Verify the file exists and is not empty
193193
$stat = @stat($backupFile);
194194
if (!$stat || $stat['size'] === 0) {
195-
throw new RuntimeException('Database backup file was not created or was empty.');
195+
throw new DbUpgradeException('Database backup file was not created or was empty.');
196196
}
197197
}
198198

@@ -209,7 +209,7 @@ protected function restoreDatabase(): void
209209
// Verify the file exists and is not empty
210210
$stat = @stat($backupFile);
211211
if (!$stat || $stat['size'] === 0) {
212-
throw new RuntimeException('Source backup file does not exist or is empty, aborting.');
212+
throw new DbUpgradeException('Source backup file does not exist or is empty, aborting.');
213213
}
214214

215215
$this->wipeDatabase();
@@ -223,7 +223,7 @@ protected function restoreDatabase(): void
223223
$export = Process::fromShellCommandline($command);
224224

225225
if ($export->run() !== 0) {
226-
throw new RuntimeException('Could not restore the database.' . PHP_EOL . $export->getErrorOutput());
226+
throw new DbUpgradeException('Could not restore the database.' . PHP_EOL . $export->getErrorOutput());
227227
}
228228
}
229229

@@ -247,7 +247,7 @@ protected function exportContent(): void
247247
$export = Process::fromShellCommandline($command);
248248

249249
if ($export->run() !== 0) {
250-
throw new RuntimeException(
250+
throw new DbUpgradeException(
251251
'Could not create a backup of the database content.' . PHP_EOL .
252252
$export->getErrorOutput()
253253
);
@@ -256,7 +256,7 @@ protected function exportContent(): void
256256
// Verify the file exists and is not empty
257257
$stat = @stat($contentFile);
258258
if (!$stat || $stat['size'] === 0) {
259-
throw new RuntimeException('Database content backup file was not created or was empty.');
259+
throw new DbUpgradeException('Database content backup file was not created or was empty.');
260260
}
261261
}
262262

@@ -319,7 +319,7 @@ protected function importContent(): void
319319
$export = Process::fromShellCommandline($command);
320320

321321
if ($export->run() !== 0) {
322-
throw new RuntimeException('Could not import the current content.' . PHP_EOL . $export->getErrorOutput());
322+
throw new DbUpgradeException('Could not import the current content.' . PHP_EOL . $export->getErrorOutput());
323323
}
324324
}
325325

@@ -394,7 +394,7 @@ protected function findExecutable($name): string
394394
$executable = $this->executableFinder->find($name);
395395

396396
if (!$executable) {
397-
throw new RuntimeException('Could not find executable ' . $name . ' on your system.');
397+
throw new DbUpgradeException('Could not find executable ' . $name . ' on your system.');
398398
}
399399

400400
return $executable;

0 commit comments

Comments
 (0)