Mark
12/20/2023, 1:00 PMerror(message: Any) accepting type Any? Doesn’t this open up the potential bug of accidentally passing a Throwable which we would normally expect to do throw IllegalStateException(cause: Throwable) ?Paul Griffith
12/20/2023, 6:33 PMerror accepting any type to lazily format into an exception message is probably more significant than the disadvantage of passing an exception type directly in.
also, cunningham’s law: there’s no way in the current type system to disallow one specific subtype but allow the restKlitos Kyriacou
12/20/2023, 6:44 PMMark
12/21/2023, 4:01 AMString and, when you don’t, you simply use .toString(). Less uncertainty regarding what is working under the hood.ephemient
01/02/2024, 8:00 PMprintln() takes Any?, so it actually seems like error does more work than necessary by requiring non-nullephemient
01/02/2024, 8:02 PMThrowable by adding an forbidden overload, e.g.
@Deprecated(level = DeprecationLevel.ERROR)
fun error(messsage: Throwable): Nothing = error(message as Any)
fun error(message: Any): Nothing = throw IllegalStateException(message.toString())ephemient
01/02/2024, 8:06 PMerror is unconditional. that would make more sense for e.g. checkNotNull, but that takes a lambda which makes it more obvious that the formatting is happening conditionally