# How many NoSuchFileException we expected?

**URL:** <https://discuss.kotlinlang.org/t/how-many-nosuchfileexception-we-expected/30680>\
**Category:** Libraries\
**Created:** [August 7, 2025, 5:01pm UTC](https://discuss.kotlinlang.org/t/how-many-nosuchfileexception-we-expected/30680 "2025-08-07T17:01:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpdyj](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@cpdyj](https://discuss.kotlinlang.org/u/cpdyj)\
**Post date:** [August 7, 2025, 5:01pm UTC](https://discuss.kotlinlang.org/t/how-many-nosuchfileexception-we-expected/30680/1 "2025-08-07T17:01:58Z")

</div>

I create a library to parse object and executable files. When the given file is not exists, I throw the `my.NoSuchFileException`. I think it’s good, because the file is really not exists.

On JVM, since there’s a `java.nio.file.NoSuchFileException`, so I `actual typealias NoSuchFileException = java.nio.file.NoSuchFileException`. I think it’s great. The JVM user can keep their styles.

On the other platform, I `actual` it with my class, since there’s no standarized one.

But now, I found I make a mess. If many libraries do this like me. Also if I create more libraries in the same way. How many NoSuchFileException we expected to handling, on non-JVM platform?

I haven’t found a way to make the best of both worlds. What about you?

What do you think of add some well-known exceptions into the stdlib? After adding them, how to evoluation them? How to make them compatible with current platform implementation?

---

<div class="post-metadata">

**Author:** ![gidds](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/gidds/32/10865_2.png) [@gidds](https://discuss.kotlinlang.org/u/gidds)\
**Post date:** [August 7, 2025, 6:15pm UTC](https://discuss.kotlinlang.org/t/how-many-nosuchfileexception-we-expected/30680/2 "2025-08-07T18:15:59Z")

</div>

The multi-platform library [kotlinx-io-core](https://kotlinlang.org/api/kotlinx-io/kotlinx-io-core/) has a [FileNotFoundException](https://kotlinlang.org/api/kotlinx-io/kotlinx-io-core/kotlinx.io.files/-file-not-found-exception/) class — on the JVM it maps to `java.io.FileNotFoundException` (which is more standard than `NoSuchFileException`), but it has other implementations too.

---

<div class="post-metadata">

**Author:** ![cpdyj](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@cpdyj](https://discuss.kotlinlang.org/u/cpdyj)\
**Post date:** [August 7, 2025, 7:17pm UTC](https://discuss.kotlinlang.org/t/how-many-nosuchfileexception-we-expected/30680/3 "2025-08-07T19:17:11Z")

</div>

That’s what I worried. We have many same name but not same type Exceptions.
