Closed Rurouni closed 3 years ago
That sounds reasonable.
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.
At the moment if you run
await Cmd("nonexistent.exe").ExecuteAsync();
it will just throw the sourceSystem.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