Bug fix #358 : pdf downoad errors in CLI were crashing the rest of the loop

This commit is contained in:
Robert McRackan 2022-08-16 15:41:12 -04:00
parent a0f3d44e97
commit e0999dc9ae
2 changed files with 14 additions and 3 deletions

View File

@ -25,9 +25,10 @@ namespace LibationCli
var downloadPdf = CreateProcessable<DownloadPdf>();
//Chain pdf download on DownloadDecryptBook.Completed
async void onDownloadDecryptBookCompleted(object sender, LibraryBook e)
void onDownloadDecryptBookCompleted(object sender, LibraryBook e)
{
await downloadPdf.TryProcessAsync(e);
// this is fast anyway. run as sync for easy exception catching
downloadPdf.TryProcessAsync(e).GetAwaiter().GetResult();
}
var downloadDecryptBook = CreateProcessable<DownloadDecryptBook>(onDownloadDecryptBookCompleted);

View File

@ -19,7 +19,17 @@ namespace LibationCli
strProc.Begin += (o, e) => Console.WriteLine($"{typeof(TProcessable).Name} Begin: {e}");
strProc.Completed += (o, e) => Console.WriteLine($"{typeof(TProcessable).Name} Completed: {e}");
strProc.Completed += completedAction;
strProc.Completed += (s, e) =>
{
try
{
completedAction?.Invoke(s, e);
}
catch (Exception ex)
{
Serilog.Log.Logger.Error(ex, "CLI error");
}
};
return strProc;
}