Reputation: 26441
I would like to initialise status
field inside constructor apart of calling super
.
class MyException : RuntimeException {
init {
val status: Status
}
constructor(status: Status) : super()
constructor(status: Status, cause: Throwable) : super(cause)
}
How can I achievie that?
Upvotes: 2
Views: 5658
Reputation: 33749
That worked for me:
class MyException : RuntimeException {
val status: Status
constructor(status: Status) : super() {
this.status = status
}
constructor(status: Status, cause: Throwable) : super(cause) {
this.status = status
}
}
Upvotes: 9