Ben Madore
09/25/2019, 7:36 PMclass PhotoLibException : RuntimeException {
constructor(message: String, ex: Exception?): super(message, ex) {}
constructor(message: String): super(message) {}
constructor(ex: Exception): super(ex) {}
}
what is the appropriate way to add another property to PhotoLibException?Dominaezzz
09/25/2019, 7:38 PMclass PhotoLibException(val newProp: PropType) : RuntimeException {
constructor(message: String, ex: Exception?): super(message, ex) {}
constructor(message: String): super(message) {}
constructor(ex: Exception): super(ex) {}
}
Ben Madore
09/25/2019, 7:40 PMopen class ErrorCodeException(val code: String?) : RuntimeException{
results in an error on RuntimeException
saying: “this type has a constructor, and thus must be initialized here”open class ErrorCodeException(val code: String?) : RuntimeException(){
then my secondary constructors fail with:
constructor(cause: Throwable, code: String? = null) : super(cause)
“Primary constructor expected”Dominaezzz
09/25/2019, 7:42 PMBen Madore
09/25/2019, 7:47 PMDominaezzz
09/25/2019, 7:50 PMclass PhotoLibException(val newProp: PropType, message: String, ex: Exception?) : RuntimeException(message, ex) {
}
ex
but I can't make assumptions.Ben Madore
09/25/2019, 7:52 PMDominaezzz
09/25/2019, 7:54 PMclass PhotoLibException() : RuntimeException {
val newProp: PropType
constructor(message: String, ex: Exception?, newProp: PropType): super(message, ex) { this.newProp = newProp }
constructor(message: String, newProp: PropType): super(message) { this.newProp = newProp }
constructor(ex: Exception, newProp: PropType): super(ex) { this.newProp = newProp }
}
Ben Madore
09/25/2019, 7:58 PMclass MyException : RuntimeException {
val code: String?
constructor(cause: Throwable, code: String? = null) : super(cause) {
this.code = code
}
constructor(message: String, code: String? = null) : super(message) {
this.code = code
}
constructor(message: String, cause: Throwable, code: String? = null) : super(message, cause) {
this.code = code
}
}