Seeker14491 / opener

Open a file or link in the system default program.
Apache License 2.0
49 stars 10 forks source link

Not enough context in error messages #12

Closed ehuss closed 1 year ago

ehuss commented 2 years ago

Some users have reported issues with using cargo on WSL where they cannot open the documentation. There are a fair number of distributions in the Microsoft Store that do not preinstall wslview. The error message is a rather difficult one to understand:

warning: couldn't open docs

IO Error

Caused by:
  No such file or directory (os error 2)

It would be helpful if the error message could provide some more context. Particularly that it is the wslview executable that cannot be found (and maybe even some more help on what to do about that). Perhaps there could be more variants of OpenError for specific errors like these?

Anytime Command.spawn is used, it might be good to wrap that error with information about which command is being executed.

Seeker14491 commented 2 years ago

The strategy on WSL is to try wslview first, then try the system xdg-open, so that error is actually produced from trying to launch a non-existing xdg-open.

I agree the error should be clearer, ideally by mentioning that neither wslview or xdg-open were found. This will involve modifying our error enum.