From 69ddb8b0ef2e434305cc15a534a04e55dc0043d0 Mon Sep 17 00:00:00 2001
From: Jochen Roth <jochen.roth@b13.com>
Date: Mon, 3 Jul 2023 11:36:42 +0200
Subject: [PATCH] [TASK] Streamline error for already filled database

Currently, when the selected db has already tables
an exception is thrown

This has been changed by showing a nicely formatted
error message like done for any other error in this command.

Resolves: #101172
Releases: main, 12.4
Change-Id: I09fe21a5cce71ff860f965244bee86474ee5c398
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79854
Tested-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: core-ci <typo3@b13.com>
---
 typo3/sysext/install/Classes/Command/SetupCommand.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/typo3/sysext/install/Classes/Command/SetupCommand.php b/typo3/sysext/install/Classes/Command/SetupCommand.php
index 12d38cc3add5..b4cdac4c24bf 100644
--- a/typo3/sysext/install/Classes/Command/SetupCommand.php
+++ b/typo3/sysext/install/Classes/Command/SetupCommand.php
@@ -296,7 +296,14 @@ EOT
                 $dbname->setValidator($dbNameValidator);
                 $databaseConnection['database'] = $questionHelper->ask($input, $output, $dbname);
             } else {
-                $dbNameValidator($dbnameFromCli);
+                try {
+                    $dbNameValidator($dbnameFromCli);
+                } catch (\RuntimeException $e) {
+                    $this->writeError($output, $e->getMessage());
+
+                    return Command::FAILURE;
+                }
+
                 $databaseConnection['database'] = $dbnameFromCli;
             }
 
-- 
GitLab