From fda355a690b24066d35b4cf30f4b9896d852bc3e Mon Sep 17 00:00:00 2001 From: Hubert Van De Walle Date: Sat, 18 Jul 2020 17:05:03 +0200 Subject: [PATCH] Handle 404 for notes --- src/controllers/web/NoteController.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/controllers/web/NoteController.kt b/src/controllers/web/NoteController.kt index db7014c..1a38f6e 100644 --- a/src/controllers/web/NoteController.kt +++ b/src/controllers/web/NoteController.kt @@ -32,8 +32,13 @@ class NoteController( suspend fun renderOne(call: ApplicationCall) { 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") call.respondKorte(template, "note" to note) }