From 3db9ccc893c5c5593fc34af3e34ab58d5de6cfd1 Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Tue, 23 Jul 2024 16:07:04 -0700 Subject: [PATCH] CLI-1327: Handle corrupt db (#1772) --- src/EventListener/ExceptionListener.php | 4 ++++ tests/phpunit/src/Misc/ExceptionListenerTest.php | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/EventListener/ExceptionListener.php b/src/EventListener/ExceptionListener.php index 1f6bdf01b..89c1dbb6f 100644 --- a/src/EventListener/ExceptionListener.php +++ b/src/EventListener/ExceptionListener.php @@ -71,6 +71,10 @@ public function onConsoleError(ConsoleErrorEvent $event): void case 'Could not extract aliases to {destination}': $this->helpMessages[] = 'Check that you have write access to the directory'; break; + case 'Unable to import local database. {message}': + $this->helpMessages[] = 'Check for MySQL warnings above or in the server log (/var/log/mysql/error.log)'; + $this->helpMessages[] = 'Frequently, `MySQL server has gone away` messages are caused by max_allowed_packet being exceeded.'; + break; } } diff --git a/tests/phpunit/src/Misc/ExceptionListenerTest.php b/tests/phpunit/src/Misc/ExceptionListenerTest.php index a46e9657d..fd6c26096 100644 --- a/tests/phpunit/src/Misc/ExceptionListenerTest.php +++ b/tests/phpunit/src/Misc/ExceptionListenerTest.php @@ -102,6 +102,13 @@ public function providerTestHelp(): array new AcquiaCliException('Could not extract aliases to {destination}'), 'Check that you have write access to the directory', ], + [ + new AcquiaCliException('Unable to import local database. {message}'), + [ + 'Check for MySQL warnings above or in the server log (/var/log/mysql/error.log)', + 'Frequently, `MySQL server has gone away` messages are caused by max_allowed_packet being exceeded.', + ], + ], [ new ApiErrorException((object) [ 'error' => '',