Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better exception for process not found #107

Closed
Rurouni opened this issue Mar 18, 2021 · 2 comments
Closed

Better exception for process not found #107

Rurouni opened this issue Mar 18, 2021 · 2 comments

Comments

@Rurouni
Copy link

Rurouni commented Mar 18, 2021

At the moment if you run await Cmd("nonexistent.exe").ExecuteAsync(); it will just throw the source
System.ComponentModel.Win32Exception: The system cannot find the file specified.
That lacks the command name and that makes it harder to investigate the errors.

I wonder if CliWrap can intercept the error during process start and wrap it into exception with a better error message like CommandExecutionException

Thank you

@Tyrrrz
Copy link
Owner

Tyrrrz commented Mar 18, 2021

That sounds reasonable.

@Tyrrrz
Copy link
Owner

Tyrrrz commented Apr 1, 2021

I looked into it and unfortunately Win32Exception is also thrown in a number of different cases besides non-existing file.

CommandExecutionException is also more focused on errors that happen when the process has already exited. Perhaps a different exception should be defined for these type of errors.

I'm leaning towards closing this as "won't fix" because it sounds like a bit too much effort for little gain. I'd recommend wrapping cmd.ExecuteAsync(...) in a try/catch and throwing a specialized exception yourself.

@Tyrrrz Tyrrrz closed this as completed Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants