在我的倉庫功能,我讀一個用戶,然後更新該用戶:如何在spray/akka中手動拋出HTTP 404 Not Found異常?
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?
}
}
我想拋出某種異常的位置,當用戶沒有找到,從而使噴塗/阿卡意志知道異常意味着返回HTTP 404 Not Found。
spray/akka是否包含某種我可以手動拋出的NotFoundException?