mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-09-12 21:57:19 -04:00
Ported from #1949, which surfaces the manual recovery steps the maintainer had been giving out by hand instead of leaving the user with a raw Lucene error. Adapted to the failure now being contained: with the exception no longer escaping into the library change, the scan-failure catch blocks #1949 hooked would never see it, and hooking only those would still miss every other trigger -- removing books is what crashed the GUI. So the guard moves from AppScaffolding into SearchEngineCommands next to the update commands it protects, and raises UpdateFailed from there. Both GUIs subscribe, so any trigger is covered, and the event carries the exception rather than needing #1949's StackTrace string sniffing to find it. The dialog is shown once per session: a damaged index fails on every library change and these steps only need following once. Co-authored-by: rmcrackan <rmcrackan@gmail.com>
43 lines
997 B
C#
43 lines
997 B
C#
using ApplicationServices;
|
|
using LibationUiBase;
|
|
using System;
|
|
using System.Windows.Forms;
|
|
|
|
namespace LibationWinForms;
|
|
|
|
public partial class Form1
|
|
{
|
|
private void Configure_SearchIndex()
|
|
=> SearchEngineCommands.UpdateFailed += searchIndexUpdateFailed;
|
|
|
|
private void searchIndexUpdateFailed(object? sender, Exception ex)
|
|
{
|
|
try
|
|
{
|
|
if (!SearchIndexRecovery.ShouldNotify())
|
|
return;
|
|
|
|
if (InvokeRequired)
|
|
{
|
|
BeginInvoke(showSearchIndexRecoveryInstructions);
|
|
return;
|
|
}
|
|
|
|
showSearchIndexRecoveryInstructions();
|
|
}
|
|
catch (Exception dialogEx)
|
|
{
|
|
// nothing above this is allowed to fail: the library change that got us here already succeeded
|
|
Serilog.Log.Logger.Error(dialogEx, "Could not show the search index recovery instructions");
|
|
}
|
|
}
|
|
|
|
private void showSearchIndexRecoveryInstructions()
|
|
=> MessageBox.Show(
|
|
this,
|
|
SearchIndexRecovery.ManualRecoveryInstructions,
|
|
SearchIndexRecovery.Caption,
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Warning);
|
|
}
|