fix more runtime exceptions D:

This commit is contained in:
Thibault Duplessis 2015-07-16 09:41:36 +02:00
parent 9435a42567
commit d923130dbb
2 changed files with 4 additions and 2 deletions

View file

@ -118,7 +118,9 @@ object JsTube {
) andThen (__ \ from).json.prune
def readDate(field: Symbol) =
(__ \ field).json.update(of[JsObject] map { o => (o \ "$date").get })
(__ \ field).json.update(of[JsObject] map { o =>
(o \ "$date").toOption err s"Can't read date of $o"
})
def readDateOpt(field: Symbol) = readDate(field) orElse json.reader

View file

@ -48,7 +48,7 @@ import play.modules.reactivemongo.json._
sort = JsObjectWriter.write(Json.obj("updatedAt" -> -1)).some)
tube.threadTube.coll.runCommand(command) map { res =>
BSONFormats.toJSON(res).arr("results").flatMap(_.apply(0).get str "value")
BSONFormats.toJSON(res).arr("results").flatMap(_.apply(0).toOption).flatMap(_ str "value")
} map {
_ ?? (_ split ';' toList)
}