9999years / command-error

An extension trait for `std::process::Command` with detailed error messages and automatic+extensible output decoding
https://docs.rs/command-error/latest/command_error/
0 stars 0 forks source link

Improving std::io::Error #18

Open artm opened 3 months ago

artm commented 3 months ago

When running a command there are in general three possible sources of std::io::Error:

  1. io error accessing the working dir
  2. io error accessing the executable
  3. io error while running the executable

The first two could happen at the same time, the third can only be encountered in the absence of the other two.

To improve the crate user's experience, whenever std::io::Error is returned by the underlying command call, it could possibly be investigated, if 1 or 2 (or both) are the case and return an error with as exact a message or two as possible. Since 1 and 2 may happen at the same time they can be captured by a single Error variant. 3 should probably be a separate variant since it will never happen simultaneously with 1-adn/or-2.

What do you think?

artm commented 3 months ago

I was mistaken about the third case: io error inside the spawned command will not be returned as std::io::Error. This makes my proposal 1/3 less valuable. Sorry for the noise :)

9999years commented 2 months ago

I'd be happy to look at a PR for this.