Hejiujiu
Hejiujiu

Reputation: 31

Kotlin custom exception with multiple parameter

So I want to throw an exception. But it contains more than just a String. something like this

class SomeException(
  val message : String,
  val someEnum : Emum,
  val customObject : CustomObject
): 

What should I extend it to? And is this even possible? I mean this exception is thrown in between microservices. throwing exceptions in rest calls should only have a string as message in it?

Upvotes: 1

Views: 4464

Answers (1)

Hejiujiu
Hejiujiu

Reputation: 31

data class SomeException(
  override val message: String,
  val someEnum : Emum,
  val customObject : CustomObject
) : Exception(message)

Upvotes: 1

Related Questions