Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def insert(account: AccountModel): Future[Long] =
- db.run((Accounts returning Accounts.map(_.id)) += account.copy(password = account.password.bcrypt)).recover {
- case ex : SQLIntegrityConstraintViolationException =>
- //TODO make this independent from actual DB
- ex.getMessage.toLowerCase match {
- case m if m.contains("FOREIGN KEY (`roleid`) REFERENCES `role` (`id`)") =>
- throw ForeignKeyException(account.roleId.get, "roleid", "account")
- case m if m.contains("duplicate") =>
- throw DuplicateRecordException("account", account.email)
- case _ => throw ex
- }
- case ex => throw ex
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement