diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2021-02-09 14:27:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-09 14:27:43 +0100 |
commit | 4c6bc62f38616c219be0667bf335c1b70f5ec1aa (patch) | |
tree | f8d642139ffe5c512e9a0347a92126cd9661c1e5 /lib | |
parent | a36186980dec315929a7e816042d613134bf7039 (diff) | |
parent | ec875227ec494edb619eee5b413d2e4dd344b4cb (diff) | |
download | nextcloud-server-4c6bc62f38616c219be0667bf335c1b70f5ec1aa.tar.gz nextcloud-server-4c6bc62f38616c219be0667bf335c1b70f5ec1aa.zip |
Merge pull request #25535 from nextcloud/query-exception-foreward
Improve exception when auto-wiring fails
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/AppFramework/Utility/SimpleContainer.php | 7 | ||||
-rw-r--r-- | lib/private/Console/Application.php | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index f73e09e645e..2aa5da116e6 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -93,7 +93,12 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer { if ($parameterType !== null && !$parameterType->isBuiltin()) { $resolveName = $parameter->getName(); - return $this->query($resolveName); + try { + return $this->query($resolveName); + } catch (QueryException $e2) { + // don't lose the error we got while trying to query by type + throw new QueryException($e2->getMessage(), (int) $e2->getCode(), $e); + } } throw $e; diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php index 10c578f41e0..9b1cc57aed3 100644 --- a/lib/private/Console/Application.php +++ b/lib/private/Console/Application.php @@ -221,7 +221,11 @@ class Application { $c = \OC::$server->query($command); } catch (QueryException $e) { if (class_exists($command)) { - $c = new $command(); + try { + $c = new $command(); + } catch (\ArgumentCountError $e2) { + throw new \Exception("Failed to construct console command '$command': " . $e->getMessage(), 0, $e); + } } else { throw new \Exception("Console command '$command' is unknown and could not be loaded"); } |