https://kotlinlang.org logo
#ktor
Title
# ktor
e

enleur

07/17/2021, 3:31 PM
which method of working with failed states in routes more idiomatic? 1.Similar to call.respondRedirect()
Copy code
val id = query["id"] ?: return@post call.respondBadRequest()
2. Using exceptions and StatusPage
Copy code
val id = query["id"]  ?: throw BadRequestException()
c

CLOVIS

07/17/2021, 7:19 PM
I've been using
val id = query["id"] ?: error("...")
but I have no idea how idiomatic it is.
a

Aleksei Tirman [JB]

07/19/2021, 12:04 PM
I would say that the second option is more idiomatic and succinct.
2 Views