diff --git a/lib/Exception/UnsupportedLogTypeException.php b/lib/Exception/UnsupportedLogTypeException.php new file mode 100644 index 00000000..c88322f0 --- /dev/null +++ b/lib/Exception/UnsupportedLogTypeException.php @@ -0,0 +1,16 @@ +config->getSystemValue('logtimezone', 'UTC'); $logType = $this->config->getSystemValue('log_type', 'file'); if ($logType !== 'file') { - throw new \Exception('Logreader application only supports "file" log_type'); + throw new UnsupportedLogTypeException(); } $log = $this->logFactory->get('file'); if ($log instanceof IFileBased) { diff --git a/lib/SetupChecks/LogErrors.php b/lib/SetupChecks/LogErrors.php index f08cf8af..b3d5646b 100644 --- a/lib/SetupChecks/LogErrors.php +++ b/lib/SetupChecks/LogErrors.php @@ -8,6 +8,7 @@ */ namespace OCA\LogReader\SetupChecks; +use OCA\LogReader\Exception\UnsupportedLogTypeException; use OCA\LogReader\Log\LogIteratorFactory; use OCP\IConfig; use OCP\IDateTimeFormatter; @@ -40,6 +41,10 @@ public function run(): SetupResult { try { $logIterator = $this->logIteratorFactory->getLogIterator([self::LEVEL_WARNING,self::LEVEL_ERROR,self::LEVEL_FATAL]); } catch (\Exception $e) { + if ($e instanceof UnsupportedLogTypeException) { + return SetupResult::info($e->getMessage()); + } + return SetupResult::error( $this->l10n->t('Failed to get an iterator for log entries: %s', [$e->getMessage()]) );