Skip to content

Commit

Permalink
Bug fix #358 : pdf downoad errors in CLI were crashing the rest of th…
Browse files Browse the repository at this point in the history
…e loop
  • Loading branch information
rmcrackan committed Aug 16, 2022
1 parent a0f3d44 commit e0999dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Source/LibationCli/Options/LiberateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ private static Processable CreateBackupBook()
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);
Expand Down
12 changes: 11 additions & 1 deletion Source/LibationCli/Options/_ProcessableOptionsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@ protected static TProcessable CreateProcessable<TProcessable>(EventHandler<Libra
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;
}
Expand Down

0 comments on commit e0999dc

Please sign in to comment.