Pattern: Object extends Throwable
Issue: -
Throwable instances are not intended for reuse as they are stateful and contain mutable information about a specific exception or error. Hence, global singleton Throwables
should be avoided.
Example of incorrect code:
object InvalidCredentialsException : Throwable()
object BanException : Exception()
object AuthException : RuntimeException()
Example of correct code:
class InvalidCredentialsException : Throwable()
class BanException : Exception()
class AuthException : RuntimeException()