From f4867763c6960c7b3372bc0044f30eda7ddf1261 Mon Sep 17 00:00:00 2001 From: Oliver Stark Date: Fri, 24 Sep 2021 16:07:15 +0200 Subject: [PATCH] 1.0.6 --- CHANGELOG.md | 1 + src/Exceptions/CraftNotInstalledException.php | 4 ++++ src/Services/Ssh.php | 21 ++++++++++--------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85b637c..2f27d67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 1.0.6 - 2021-09-24 - Exclude `resourcepaths` table from db backup - Ignore mysql import errors 🤞🏻 +- Better error output ## 1.0.5 - 2021-05-12 - Update craft-auto-migrate to use `project-config/apply` diff --git a/src/Exceptions/CraftNotInstalledException.php b/src/Exceptions/CraftNotInstalledException.php index fb7dd4f..d61b00d 100644 --- a/src/Exceptions/CraftNotInstalledException.php +++ b/src/Exceptions/CraftNotInstalledException.php @@ -6,4 +6,8 @@ class CraftNotInstalledException extends RemoteException { + /** + * @var string + */ + public $message = 'Craft is not installed on the fortrabbit App.'; } diff --git a/src/Services/Ssh.php b/src/Services/Ssh.php index 623ab5e..ec30a3c 100644 --- a/src/Services/Ssh.php +++ b/src/Services/Ssh.php @@ -125,16 +125,17 @@ public function exec(string $cmd) return true; } - if (trim($process->getErrorOutput()) === 'Could not open input file') { - throw new CraftNotInstalledException( - trim($process->getErrorOutput()) - ); - } + $out = $process->getOutput(); + $err = $process->getOutput(); - if (stristr($process->getErrorOutput(), 'Unknown command')) { - throw new PluginNotInstalledException( - 'The Craft Copy plugin is not installed on remote.' - ); + if (stristr($out, 'Could not open input file')) { + throw new CraftNotInstalledException(); + } + if (stristr($err, 'Could not open input file')) { + throw new CraftNotInstalledException(); + } + if (stristr($err, 'Unknown command')) { + throw new PluginNotInstalledException(); } throw new RemoteException( @@ -142,7 +143,7 @@ public function exec(string $cmd) 'SSH Remote error: ' . $process->getExitCode(), 'Command: ' . $process->getCommandLine(), 'Output:', - $process->getErrorOutput(), + $err, ]) ); }