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?