0

I have a simple doobie batch insert:

def insertMe(data: List[SomeData]): ConnectionIO[Unit] = {
  insert("Insert into some_table (name, age) values (data.name, data.age)")(data)
}

private def insert[T: Write](sql: String)(data: Iterable[T]): ConnectionIO[Unit] = Update[T](sql).updateMany(data.toList).void

It works fine where all data is correct. But when I get incorrect data (for example name length to long), I got SQL error and everything fails. My goal is to continue application run even when error appears, obly log this info but do not abort it. I tried to do something like continueOnError, but Doobie does not have this one. How it is possible to handle error when one batch fails and continue?

Developus
  • 1,400
  • 2
  • 14
  • 50
  • 1
    Have you checked this? https://tpolecat.github.io/doobie/docs/09-Error-Handling.html there are couple of suggestinos – michaJlS May 25 '23 at 16:38

0 Answers0