0

I am new to slick and I need some help with the following error:

 java.sql.BatchUpdateException: Batch entry 0 insert into "USER_PROFILE" ... Call getNextException to see the cause.

The code which causes this error is (the last line of it):

def insertUserProfileEvents(events: Seq[UserProfile]) = {
    implicit val session = DbGateway.getSession
    val userProfiles = TableQuery[UserProfileTable]
    (userProfiles ++= events).run
}

How do I make the error being more informative?
Maybe I should look for logs in postgres itself? Thanks.

Eli Golin
  • 373
  • 1
  • 16

1 Answers1

0

Apparently all that's need to be done is surrounding the exception throwing lines with Scala's Try:

def insertUserProfileEvents(events: Seq[UserProfile]) = {
    implicit val session = DbGateway.getSession
    val userProfiles = TableQuery[UserProfileTable]
    Try{(userProfiles ++= events).run} match { case Failure(ex) => println(ex)
}
Eli Golin
  • 373
  • 1
  • 16