Does Exception/Throwable have a special status of ...
# announcements
a
Does Exception/Throwable have a special status of same kind? Would it be okay to carry an additional state and functionality within Exception class?
k
Sure, there's no problem with that.
a
Java's Exception seems to follow pattern of no additional state nor methods. I have no clue if it's a contract of some kind or just coincidence.
I'm actually trying to convince people not to put any extra stuff in exception classes.
But Serialization is the only argument I got so far
k
Well the saying goes "don't use exceptions for control logic", so if you're going to be catching exceptions and get information out of the in the
catch
block maybe it's better to return some kind of result class.
a
No they got additional methods for logging and persistence within Exception. Which feels odd to me.
k
You could look into error handling with Arrow with a Try or Either object https://arrow-kt.io/docs/patterns/error_handling/
👍 1