# Exceptions, Throwables, Errors, which course to take?

**URL:** <https://discuss.kotlinlang.org/t/exceptions-throwables-errors-which-course-to-take/122>\
**Category:** Uncategorized\
**Created:** [September 14, 2015, 9:32am UTC](https://discuss.kotlinlang.org/t/exceptions-throwables-errors-which-course-to-take/122 "2015-09-14T09:32:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mplatvoet](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/mplatvoet/32/7121_2.png) [@mplatvoet](https://discuss.kotlinlang.org/u/mplatvoet)\
**Post date:** [September 14, 2015, 9:32am UTC](https://discuss.kotlinlang.org/t/exceptions-throwables-errors-which-course-to-take/122/1 "2015-09-14T09:32:41Z")

</div>

Hello everybody. I'm a bit lost at the moment with `Exception`s in Kotlin and what course to take with a library API. From [kotlinlang.org](http://kotlinlang.org/) it states that:

 

> All 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&nbsp;&nbsp;should I use to properly facilitate Exception handling?&nbsp;&nbsp;I now use ``Promise<Foo, Exception>`` in my API of Kovenant.&nbsp;&nbsp;But this already leads to usability issues, as pointed out by [@jaysonminard](https://kotlinlang.slack.com/team/jaysonminard), 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&lt;Foo, Throwable&gt;` 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?

---

<div class="post-metadata">

**Author:** ![abreslav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/abreslav/32/8279_2.png) [@abreslav](https://discuss.kotlinlang.org/u/abreslav)\
**Post date:** [September 14, 2015, 11:00am UTC](https://discuss.kotlinlang.org/t/exceptions-throwables-errors-which-course-to-take/122/2 "2015-09-14T11:00:11Z")

</div>

It's a mistake in the docs. You can use Throwable.

---

<div class="post-metadata">

**Author:** ![mplatvoet](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/mplatvoet/32/7121_2.png) [@mplatvoet](https://discuss.kotlinlang.org/u/mplatvoet)\
**Post date:** [September 14, 2015, 5:58pm UTC](https://discuss.kotlinlang.org/t/exceptions-throwables-errors-which-course-to-take/122/3 "2015-09-14T17:58:45Z")

</div>

Okay thanks, so the intent/implementation is that Throwable maps to JavaScripts Error object?

Update: I see this indeed works perfectly on JavaScript as well.

---

<div class="post-metadata">

**Author:** ![marco.s](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/marco.s/32/6781_2.png) [@marco.s](https://discuss.kotlinlang.org/u/marco.s)\
**Post date:** [October 1, 2019, 11:23am UTC](https://discuss.kotlinlang.org/t/exceptions-throwables-errors-which-course-to-take/122/4 "2019-10-01T11:23:13Z")

</div>

I think that there is a distinction to be made here when we talk about **Java** , and I’m posting it on this old thread just to clarify.  
You _can_ use `Throwable` in Kotlin, but you must ask yourself if you _should_ use it.  
End-user applications and client code should rarely handle try/catch and error management with `Throwable`. One of its implementations is the unchecked exception `Error`; and the [documentation](https://docs.oracle.com/javase/8/docs/api/java/lang/Error.html) for it is very clear:

> An `Error` is a subclass of `Throwable` that indicates serious problems that a reasonable application should not try to catch.

Normal application code should only deal with `Exception` and its subclasses.
