【发布时间】:2017-12-31 04:46:57
【问题描述】:
在我的存储库函数中,我正在读取一个用户,然后更新该用户:
def update(u: User): Future[Int] = {
this.read(u.id).flatMap {
case Some(existingUser) =>
db.run(
userTable
.filter(_.id === user.id)
.update(user.copy(createdDate = existingUser.createdDate)))
//case None => throw new NotFoundException(); // does this exception exist in spray/akka?
}
}
当找不到用户时,我想在这里抛出某种异常,以便 spray/akka 知道异常意味着返回 HTTP 404 Not Found。
spray/akka 是否包含某种我可以手动抛出的 NotFoundException?
【问题讨论】:
标签: scala akka slick spray slick-3.0