Merge pull request #25535 from nextcloud/query-exception-foreward

Improve exception when auto-wiring fails
This commit is contained in:
Christoph Wurst 2021-02-09 14:27:43 +01:00 committed by GitHub
commit 4c6bc62f38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -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;

View File

@ -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");
}