Skip to content

Commit

Permalink
Nicer error output
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed May 8, 2024
1 parent 369807d commit ed76452
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 26 deletions.
11 changes: 9 additions & 2 deletions src/controllers/InstallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use craft\helpers\ArrayHelper;
use craft\helpers\Install as InstallHelper;
use craft\helpers\StringHelper;
use craft\markdown\Markdown;
use craft\migrations\Install;
use craft\models\Site;
use craft\web\assets\installer\InstallerAsset;
Expand Down Expand Up @@ -299,9 +300,15 @@ public function actionInstall(): Response
try {
$migrator->migrateUp($migration);
} catch (MigrationException $e) {
$data = [];
$previous = $e->getPrevious();
$message = $previous instanceof OperationAbortedException ? $previous->getMessage() : $e->getMessage();
return $this->asFailure($message);
if ($previous instanceof OperationAbortedException) {
$message = $previous->getMessage();
$data['messageHtml'] = (new Markdown())->parse($message);
} else {
$message = $e->getMessage();
}
return $this->asFailure($message, $data);
}

// Mark all existing migrations as applied
Expand Down
5 changes: 3 additions & 2 deletions src/migrations/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ class Install extends Migration
public function safeUp(): bool
{
if (!$this->_validateProjectConfig($error)) {
echo "\nProject config validation failed: $error\n\nAborting install.\n\n";
throw new OperationAbortedException("Project config validation failed: $error");
$message = "Project config validation failed: $error\n\nRun `composer install` or remove your `config/project/` folder and try again.";
echo "\n$message\n\nAborting install.\n\n";
throw new OperationAbortedException($message);
}

$this->createTables();
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/installer/dist/css/install.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/web/assets/installer/dist/css/install.css.map

Large diffs are not rendered by default.

Loading

0 comments on commit ed76452

Please sign in to comment.