Skip to content

Commit

Permalink
Merge pull request #2786 from ministryofjustice/chore/rollback-seed-j…
Browse files Browse the repository at this point in the history
…ob-on-any-errors

Rollback seed transaction if any errors occur
  • Loading branch information
davidatkinsuk authored Jan 10, 2025
2 parents 54a83ff + abfc540 commit 6969bb2
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class SeedService(
return rowsProcessed
}

@SuppressWarnings("TooGenericExceptionThrown")
private fun <T> processCsv(job: SeedJob<T>, resolveCsvPath: SeedJob<T>.() -> String): Int {
var rowNumber = 1
val errors = mutableListOf<String>()
Expand All @@ -147,7 +148,7 @@ class SeedService(
throw RuntimeException("Unable to process CSV at row $rowNumber", exception)
}
if (errors.isNotEmpty()) {
seedLogger.error("The following row-level errors were raised: ${errors.joinToString("\n")}")
throw RuntimeException("The following row-level errors were raised: ${errors.joinToString("\n")}")
}

return rowNumber - 1
Expand Down

0 comments on commit 6969bb2

Please sign in to comment.