diff --git a/apps/dav/lib/Settings/AvailabilitySettings.php b/apps/dav/lib/Settings/AvailabilitySettings.php index 085569331680c..ff32485c20248 100644 --- a/apps/dav/lib/Settings/AvailabilitySettings.php +++ b/apps/dav/lib/Settings/AvailabilitySettings.php @@ -28,6 +28,7 @@ use OCA\DAV\AppInfo\Application; use OCA\DAV\Db\AbsenceMapper; +use OCA\Mail\Vendor\Psr\Log\LoggerInterface; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Services\IInitialState; @@ -42,6 +43,7 @@ class AvailabilitySettings implements ISettings { public function __construct(IConfig $config, IInitialState $initialState, ?string $userId, + private LoggerInterface $logger, private AbsenceMapper $absenceMapper) { $this->config = $config; $this->initialState = $initialState; @@ -68,7 +70,13 @@ public function getForm(): TemplateResponse { try { $absence = $this->absenceMapper->findByUserId($this->userId); $this->initialState->provideInitialState('absence', $absence); - } catch (DoesNotExistException|\OCP\DB\Exception) { + } catch (DoesNotExistException) { + // The user has not yet set up an absence period. + // Logging this error is not necessary. + } catch (\OCP\DB\Exception $e) { + $this->logger->error("Could not find absence data for user $this->userId: " . $e->getMessage(), [ + 'exception' => $e, + ]); } }