mplatvoet
09/14/2015, 9:26 AMAll exception classes in Kotlin are descendants of the class Exception.In the Java landscape we have
Exception
and Error
and the shared parent Throwable
. In the JavaScript landscape we have `Error`s. (I know the focus is on 1.0 and Java at the moment).
If I want to create a future proof API, so also supporting JavaScript in the future, what approach should I use to properly facilitate Exception handling? I now use Promise<Foo, Exception>
in my API of Kovenant. But this already leads to usability issues, as pointed out by @apatrida, in cases where other (java) libraries/frameworks are used that have Throwable
in their interface. It seems that not all Throwables are descendants of the class Exception.
I don't want to change the signature to Promise<Foo, Throwable>
as I believe that doesn't work with javascript implementations, or does it? So will there be (somewhere in the future) some generalized Exception class that plays well with all supported languages or am I overlooking something already?