I’m entirely not sure how Kotlin secondary-constructor syntax would have to change to support this. Perhaps a special exception could be thrown like this?
Copy code
class Foo(val bar: Bar) {
constructor?(barString: String): this(bar = Bar.fromStringOrNull(barString) ?: throw ConstructionFailedException())
}