From cb24373921bbb23f8e44dc9e6402ec39cf973217 Mon Sep 17 00:00:00 2001 From: Adrian Granado Date: Thu, 21 Dec 2017 12:54:34 +0100 Subject: [PATCH 1/3] Controlled exception on find_latest_package (Github Driver) --- src/Package_Command.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Package_Command.php b/src/Package_Command.php index 4340c0eb6..c170f1bf7 100644 --- a/src/Package_Command.php +++ b/src/Package_Command.php @@ -676,10 +676,14 @@ private function show_packages( $context, $packages, $assoc_args ) { $update = 'none'; $update_version = ''; if ( 'list' === $context ) { - $latest = $this->find_latest_package( $package, $this->get_composer(), null ); - if ( $latest && $latest->getFullPrettyVersion() !== $package->getFullPrettyVersion() ) { - $update = 'available'; - $update_version = $latest->getPrettyVersion(); + try { + $latest = $this->find_latest_package( $package, $this->get_composer(), null ); + if ( $latest && $latest->getFullPrettyVersion() !== $package->getFullPrettyVersion() ) { + $update = 'available'; + $update_version = $latest->getPrettyVersion(); + } + } catch (\Exception $e) { + $update = $update_version = 'Error whith Github Driver'; } } $package_output['update'] = $update; From 31346ebad4723a9fee6620dd25ab74c7e75f1b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Granado?= Date: Thu, 21 Dec 2017 12:59:24 +0100 Subject: [PATCH 2/3] Update Package_Command.php --- src/Package_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Package_Command.php b/src/Package_Command.php index c170f1bf7..666b5a341 100644 --- a/src/Package_Command.php +++ b/src/Package_Command.php @@ -682,7 +682,7 @@ private function show_packages( $context, $packages, $assoc_args ) { $update = 'available'; $update_version = $latest->getPrettyVersion(); } - } catch (\Exception $e) { + } catch (Exception $e) { $update = $update_version = 'Error whith Github Driver'; } } From 35e92ed6894bc932be8cc1599a1319df3649bf94 Mon Sep 17 00:00:00 2001 From: gitlost Date: Wed, 3 Jan 2018 12:10:00 +0000 Subject: [PATCH 3/3] Set simple "error" message in table on exception and warn with full message. --- src/Package_Command.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Package_Command.php b/src/Package_Command.php index 666b5a341..c9fff9175 100644 --- a/src/Package_Command.php +++ b/src/Package_Command.php @@ -682,8 +682,9 @@ private function show_packages( $context, $packages, $assoc_args ) { $update = 'available'; $update_version = $latest->getPrettyVersion(); } - } catch (Exception $e) { - $update = $update_version = 'Error whith Github Driver'; + } catch ( Exception $e ) { + WP_CLI::warning( $e->getMessage() ); + $update = $update_version = 'error'; } } $package_output['update'] = $update;