diff --git a/Source/LibationCli/Options/LiberateOptions.cs b/Source/LibationCli/Options/LiberateOptions.cs index 6563c778..5c904771 100644 --- a/Source/LibationCli/Options/LiberateOptions.cs +++ b/Source/LibationCli/Options/LiberateOptions.cs @@ -25,9 +25,10 @@ namespace LibationCli var downloadPdf = CreateProcessable(); //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(onDownloadDecryptBookCompleted); diff --git a/Source/LibationCli/Options/_ProcessableOptionsBase.cs b/Source/LibationCli/Options/_ProcessableOptionsBase.cs index 0897c6b9..e4b255e1 100644 --- a/Source/LibationCli/Options/_ProcessableOptionsBase.cs +++ b/Source/LibationCli/Options/_ProcessableOptionsBase.cs @@ -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; }