Handle 404 for notes

This commit is contained in:
Hubert Van De Walle 2020-07-18 17:05:03 +02:00
parent fc883373d0
commit fda355a690

View File

@ -32,8 +32,13 @@ class NoteController(
suspend fun renderOne(call: ApplicationCall) { suspend fun renderOne(call: ApplicationCall) {
val uuidParam = call.parameters["uuid"] val uuidParam = call.parameters["uuid"]
val uuid = UUID.fromString(uuidParam)
val note = noteRepository.find(userId = 1, noteUuid = uuid) val uuid = try {
UUID.fromString(uuidParam)
} catch (e: RuntimeException) {
return
}
val note = noteRepository.find(userId = 1, noteUuid = uuid) ?: return
val template = templates.get("_uuid.html") val template = templates.get("_uuid.html")
call.respondKorte(template, "note" to note) call.respondKorte(template, "note" to note)
} }