Skip to content

Commit

Permalink
BE: Handling errors the same way as warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
StaNov committed Dec 18, 2024
1 parent 5f97cec commit 709726e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ class CoreImportFilesProcessor(
)
}

val errors = mutableListOf<ErrorResponseBody>()
val warnings = mutableListOf<ErrorResponseBody>()

fun processFiles(files: Collection<ImportFileDto>?): List<ErrorResponseBody> {
val errors = processFilesRecursive(files)
fun processFiles(files: Collection<ImportFileDto>?) {
errors.addAll(processFilesRecursive(files))
renderPossibleNamespacesWarning()
return errors
}

private fun processFilesRecursive(files: Collection<ImportFileDto>?): List<ErrorResponseBody> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Serializable>)
throw BadRequestException(Message.IMPORT_FAILED, fileProcessor.errors as List<Serializable>)
}

if (fileProcessor.importDataManager.storedLanguages.isEmpty()) {
Expand Down

0 comments on commit 709726e

Please sign in to comment.