From 709726e23d06cd2974af43de1e140daeb30ba127 Mon Sep 17 00:00:00 2001 From: StaNov Date: Wed, 18 Dec 2024 14:10:45 +0100 Subject: [PATCH] BE: Handling errors the same way as warnings --- .../service/dataImport/CoreImportFilesProcessor.kt | 6 +++--- .../io/tolgee/service/dataImport/ImportService.kt | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/data/src/main/kotlin/io/tolgee/service/dataImport/CoreImportFilesProcessor.kt b/backend/data/src/main/kotlin/io/tolgee/service/dataImport/CoreImportFilesProcessor.kt index fbc4801060..973322f2ba 100644 --- a/backend/data/src/main/kotlin/io/tolgee/service/dataImport/CoreImportFilesProcessor.kt +++ b/backend/data/src/main/kotlin/io/tolgee/service/dataImport/CoreImportFilesProcessor.kt @@ -57,12 +57,12 @@ class CoreImportFilesProcessor( ) } + val errors = mutableListOf() val warnings = mutableListOf() - fun processFiles(files: Collection?): List { - val errors = processFilesRecursive(files) + fun processFiles(files: Collection?) { + errors.addAll(processFilesRecursive(files)) renderPossibleNamespacesWarning() - return errors } private fun processFilesRecursive(files: Collection?): List { diff --git a/backend/data/src/main/kotlin/io/tolgee/service/dataImport/ImportService.kt b/backend/data/src/main/kotlin/io/tolgee/service/dataImport/ImportService.kt index 59069ef5f2..5c57d9bb35 100644 --- a/backend/data/src/main/kotlin/io/tolgee/service/dataImport/ImportService.kt +++ b/backend/data/src/main/kotlin/io/tolgee/service/dataImport/ImportService.kt @@ -99,12 +99,12 @@ class ImportService( projectIcuPlaceholdersEnabled = project.icuPlaceholders, importSettings = importSettingsService.get(userAccount, project.id), ) - val errors = fileProcessor.processFiles(files) + fileProcessor.processFiles(files) if (findLanguages(import).isEmpty()) { TransactionInterceptor.currentTransactionStatus().setRollbackOnly() } - return errors to fileProcessor.warnings + return fileProcessor.errors to fileProcessor.warnings } @Transactional @@ -135,11 +135,11 @@ class ImportService( importSettings = params, saveData = false, ) - val errors = fileProcessor.processFiles(files) + fileProcessor.processFiles(files) - if (errors.isNotEmpty()) { + if (fileProcessor.errors.isNotEmpty()) { @Suppress("UNCHECKED_CAST") - throw BadRequestException(Message.IMPORT_FAILED, errors as List) + throw BadRequestException(Message.IMPORT_FAILED, fileProcessor.errors as List) } if (fileProcessor.importDataManager.storedLanguages.isEmpty()) {