Skip to content

Commit a915b45

Browse files
authored
Merge pull request #21461 from nextcloud/fix/catch-app-register-boot-exceptions
Catch all exceptions when an app is registering or booting
2 parents 3ac0484 + 5ab5a5f commit a915b45

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/private/AppFramework/Bootstrap/Coordinator.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use OCP\EventDispatcher\IEventDispatcher;
3333
use OCP\ILogger;
3434
use OCP\IServerContainer;
35+
use Throwable;
3536
use function class_exists;
3637
use function class_implements;
3738
use function in_array;
@@ -81,9 +82,17 @@ public function runRegistration(): void {
8182
try {
8283
/** @var IBootstrap|App $application */
8384
$apps[$appId] = $application = $this->serverContainer->query($applicationClassName);
84-
$application->register($context->for($appId));
8585
} catch (QueryException $e) {
8686
// Weird, but ok
87+
return;
88+
}
89+
try {
90+
$application->register($context->for($appId));
91+
} catch (Throwable $e) {
92+
$this->logger->logException($e, [
93+
'message' => 'Error during app service registration: ' . $e->getMessage(),
94+
'level' => ILogger::FATAL,
95+
]);
8796
}
8897
}
8998
}
@@ -125,6 +134,11 @@ public function bootApp(string $appId): void {
125134
'message' => "Could not boot $appId" . $e->getMessage(),
126135
]);
127136
return;
137+
} catch (Throwable $e) {
138+
$this->logger->logException($e, [
139+
'message' => "Could not boot $appId" . $e->getMessage(),
140+
'level' => ILogger::FATAL,
141+
]);
128142
}
129143
}
130144
}

0 commit comments

Comments
 (0)