🐛 Fix Error Handling of Job Factory

This commit is contained in:
Gerrit 2023-08-03 10:34:31 +02:00
parent a22a3b0cfd
commit 49ee9b1079
3 changed files with 16 additions and 13 deletions

View file

@ -30,7 +30,9 @@ namespace AmagnoVirtualPrinter.Agent.Lib.Misc
[NotNull]
private readonly IJobProcessor _jobProcessor;
private IDirectoryHelper _directoryHelper;
[NotNull]
private readonly IDirectoryHelper _directoryHelper;
private TcpListener _socket;
private FileSystemWatcher _watcher;
private string _outputDir;
@ -101,20 +103,21 @@ namespace AmagnoVirtualPrinter.Agent.Lib.Misc
LogDebug($"{remote} --> {local}");
job = _jobFactory.Create(printer, client.GetStream());
if (job == null)
{
LogError("Job could not be created.");
return;
}
}
LogDebug($"Temporarily printed '{job.RawDataPath}'!");
socket.BeginAcceptTcpClient(HandleClient, ar.AsyncState);
if (job == null)
{
LogError("Job could not be created. Check your Printer Settings.");
}
else
{
LogDebug($"Temporarily printed '{job.RawDataPath}'!");
_jobService.Start(job);
RestartFileWatcherIfNeeded(job.SessionInfo.Sid);
}
}
private void RestartFileWatcherIfNeeded(string sid)
{

View file

@ -97,7 +97,7 @@ namespace AmagnoVirtualPrinter.Utils
}
[ContractAnnotation("key:null => void")]
private void CheckForNull(RegistryKey key, string keyName)
private static void CheckForNull(RegistryKey key, string keyName)
{
if (key == null)
{