https://kotlinlang.org logo
#codereview
Title
# codereview
h

hho

06/28/2021, 4:08 PM
Kotlin has 1️⃣
check(…)
and 2️⃣
require(…)
. Which would be better to signal an invalid configuration (i.e. on startup)? Or should I make up 3️⃣ my own exception class? I'm really torn between "a bad config is an illegal argument" and "the app is in an illegal state and can't start" 😕
z

Zach Klippenstein (he/him) [MOD]

06/28/2021, 4:13 PM
Where’s the configuration coming from? If it’s read from a file or some other external resource, I would argue that IAE is definitely the wrong thing since that exception explicitly means a bad argument was passed to a function. Not sure if ISE would necessarily be any more correct either though.
h

hho

06/28/2021, 4:16 PM
Yep, external config (k8s template).
z

Zach Klippenstein (he/him) [MOD]

06/28/2021, 5:16 PM
I would probably make a dedicated exception (inheriting from
RuntimeException
probably)
1
4 Views