1

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?

1
  • The structure of your exceptions totally depends on what your needs are. Mine for example always contain a code: String a userMessage: String (something that can be displayed to the end-user) and a developerMessage: String (further and more technical info for developers). If you're in Kotlin then extending Exception is fine. Maybe RuntimeException if you're also dealing with Java. Commented Aug 26, 2020 at 18:34

1 Answer 1

1
data class SomeException( override val message: String, val someEnum : Emum, val customObject : CustomObject ) : Exception(message) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.