# Exhaustive ErrorKind for linux errors

**URL:** <https://internals.rust-lang.org/t/exhaustive-errorkind-for-linux-errors/23552>\
**Category:** language design\
**Created:** [September 20, 2025, 11:13am UTC](https://internals.rust-lang.org/t/exhaustive-errorkind-for-linux-errors/23552 "2025-09-20T11:13:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PrasannaPaithankar](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/prasannapaithankar/32/12069_2.png) [@PrasannaPaithankar](https://internals.rust-lang.org/u/PrasannaPaithankar)\
**Post date:** [September 20, 2025, 11:13am UTC](https://internals.rust-lang.org/t/exhaustive-errorkind-for-linux-errors/23552/1 "2025-09-20T11:13:32Z")

</div>

(Constraining the discussion to only linux)

We can get the errno from [errno()](https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/unix/os.rs#L58)

The [decode\_error\_kind(errno: i32) -\> ErrorKind](https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/unix/mod.rs#L238) function maps the libc::_some\_error\_type_ to [ErrorKind](https://github.com/rust-lang/rust/blob/master/library/std/src/io/error.rs#L228) enum member.

**Issue**

The ErrorKind only defines I/O related errors. Non I/O Errors like ENOSPC or ECANCELED, etc are not part of ErrorKind.

Shouldn't the ErrorKind enum be expanded to include all errors so that we can also have to\_string for each of them making error logging easier.

---

<div class="post-metadata">

**Author:** ![bjorn3](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/bjorn3/32/2736_2.png) [@bjorn3](https://internals.rust-lang.org/u/bjorn3)\
**Post date:** [September 20, 2025, 11:41am UTC](https://internals.rust-lang.org/t/exhaustive-errorkind-for-linux-errors/23552/2 "2025-09-20T11:41:13Z")

</div>

> [@PrasannaPaithankar](#):
>
> Shouldn't the ErrorKind enum be expanded to include all errors so that we can also have to\_string for each of them making error logging easier.

`Error::to_string()` should internally call `strerror_r` if it was derived from a libc error code. This will give the error code description irrespective of which `ErrorKind` it maps to.

> <https://github.com/rust-lang/rust/blob/b00998aaa50a78b1e45fb107a6c0cfd3f1dc44dd/library/std/src/io/error.rs#L1042-L1045>

---

<div class="post-metadata">

**Author:** ![zackw](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/zackw/32/2071_2.png) [@zackw](https://internals.rust-lang.org/u/zackw)\
**Post date:** [September 20, 2025, 12:30pm UTC](https://internals.rust-lang.org/t/exhaustive-errorkind-for-linux-errors/23552/3 "2025-09-20T12:30:05Z")

</div>

Feels closely related to [Tracking Issue for io\_error\_more · Issue #86442 · rust-lang/rust · GitHub](https://github.com/rust-lang/rust/issues/86442), although I don't think that was going for _exhaustive_.

There are a bunch of errno codes that are defined only for backward source compat with obsolete oddities like RFS and STREAMS; current kernels will never generate them. I don't think we need those in `ErrorKind`. Unfortunately there's no easy way to know which ones they are.
