diff --git a/server/src/main/scala/za/co/absa/atum/server/model/CheckpointItemWithPartitioningFromDB.scala b/server/src/main/scala/za/co/absa/atum/server/model/CheckpointItemWithPartitioningFromDB.scala index 73653938..996bb207 100644 --- a/server/src/main/scala/za/co/absa/atum/server/model/CheckpointItemWithPartitioningFromDB.scala +++ b/server/src/main/scala/za/co/absa/atum/server/model/CheckpointItemWithPartitioningFromDB.scala @@ -113,12 +113,8 @@ object CheckpointItemWithPartitioningFromDB { val result = orderedCheckpointIds.map { id => fromItemsToCheckpointWithPartitioningDTO(groupedItems(id)) } - val errors = result.collect { case Left(err) => err } - if (errors.nonEmpty) { - Left(errors.head) - } else { - Right(result.collect { case Right(dto) => dto }) - } + val error = result.collectFirst { case Left(err) => Left(err) } + error.getOrElse(Right(result.collect { case Right(dto) => dto })) } }