https://kotlinlang.org logo
Title
d

Dariusz Kuc

02/02/2023, 10:35 PM
Hello 👋 Whats the proper way to define required properties/configuration for a custom plugin? docs here show optional values with fallback to default -> https://ktor.io/docs/custom-plugins.html#configuration-file should I mark those as
lateinit
? or maybe by using
Delegates.notNull()
? or is there some more elegant way to do it?
s

spand

02/03/2023, 9:31 AM
I am not sure if the config has a handle for reporting these cases but otherwise it seems defining the fallback as
?: error("config is mandatory but was missing")
would be better than whatever funky errors lateinit or notNull produces
d

Dariusz Kuc

02/03/2023, 2:42 PM
yeah its just I wish there was a way to communicate to user
if you install this plugin you need to configure those properties
(failure at build time - compiler would complain) vs failing at runtime with the info
a

Aleksei Tirman [JB]

02/07/2023, 8:19 PM
Unfortunately, this isn’t possible because a plugin instantiates its configuration object and a user who configures the plugin can only mutate configuration object.