# System errors

**URL:** <https://internals.rust-lang.org/t/system-errors/1724>\
**Category:** libs\
**Created:** [March 16, 2015, 7:20pm UTC](https://internals.rust-lang.org/t/system-errors/1724 "2015-03-16T19:20:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jan\_hudec](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/jan_hudec/32/4100_2.png) [@jan\_hudec](https://internals.rust-lang.org/u/jan_hudec)\
**Post date:** [March 16, 2015, 7:20pm UTC](https://internals.rust-lang.org/t/system-errors/1724/1 "2015-03-16T19:20:53Z")

</div>

The `std::os::errno()` started shouting at me that it’s deprecated. With slightly misleading warning that it should be replaced by functions from `std::env` which applies to most `std::os` but not this particular function.

The only replacement I could find is `std::io::Error::last_os_error()`, but it is not completely adequate, because it can only distinguish the IO-related errors. But I need values like `E2BIG` and `EILSEQ`. System-specific values are OK, because the function is system-specific too. Actually looking at the source it seems it carries the errno value along, but I see no way to get to it from the interface.

Is there any better replacement? Will the io::Error be extended or should there be another replacement?

---

<div class="post-metadata">

**Author:** ![alexcrichton](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/alexcrichton/32/4501_2.png) [@alexcrichton](https://internals.rust-lang.org/u/alexcrichton)\
**Post date:** [March 17, 2015, 1:03am UTC](https://internals.rust-lang.org/t/system-errors/1724/2 "2015-03-17T01:03:52Z")

</div>

Yes we plan on allowing access of the error code within `io::Error` (this should happen soon). For now `#[allow(deprecated)]` on a small function should do the trick!

---

<div class="post-metadata">

**Author:** ![lambda-fairy](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/lambda-fairy/32/2045_2.png) [@lambda-fairy](https://internals.rust-lang.org/u/lambda-fairy)\
**Post date:** [March 29, 2015, 10:23am UTC](https://internals.rust-lang.org/t/system-errors/1724/3 "2015-03-29T10:23:13Z")

</div>

I had your exact issue a few days ago!

I solved it by extracting the `errno` code into its own crate: [https://crates.io/crates/errno](https://crates.io/crates/errno)

This should be a decent stop-gap, at least until the functionality is added back to `std`.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 25, 2019, 8:24am UTC](https://internals.rust-lang.org/t/system-errors/1724/4 "2019-03-25T08:24:04Z")

</div>

Closed on March 25, 2019, 8:24am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
