I am new to using C # and .NET, but want to try to reproduce nice and reuse system components.
In the code that I support, there are several cases where we run external tools and applications that look something like this:
using (var Setup = Process.Start(SetupInfo) )
{
Setup.WaitForExit(SetupTimeout);
if (!Setup.HasExited )
throw new TimeoutException(
"Setup did not complete within the expected time");
}
I am trying to add an exit code check also for those external tools that have well-defined exit codes, i.e. something like this inside the using block:
switch ( Setup.ExitCode )
{
case 0:
break;
case 1:
throw new SetupFailedException("Setup execution failed");
case 2:
throw new SetupFileNotFound("Setup did not find required files");
default:
throw new ExternalErrorException("Setup failed for some other reason");
}
... "ExternalErrorException". - , , , , , , ?