Skip to content

Commit 51f5d8a

Browse files
Add new constructor for EngineNotAvailableException
1 parent 52e7299 commit 51f5d8a

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Exceptions/EngineNotAvailableException.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
using System;
44
using System.Threading.Tasks;
55
using System.Windows;
6-
using Flow.Launcher.Plugin.Explorer.Search.IProvider;
7-
using JetBrains.Annotations;
86

97
namespace Flow.Launcher.Plugin.Explorer.Exceptions;
108

@@ -20,7 +18,7 @@ public EngineNotAvailableException(
2018
string engineName,
2119
string resolution,
2220
string message,
23-
Func<ActionContext, ValueTask<bool>> action = null) : base(message)
21+
Func<ActionContext, ValueTask<bool>>? action = null) : base(message)
2422
{
2523
EngineName = engineName;
2624
Resolution = resolution;
@@ -40,6 +38,23 @@ public EngineNotAvailableException(
4038
EngineName = engineName;
4139
Resolution = resolution;
4240
}
41+
42+
public EngineNotAvailableException(
43+
string engineName,
44+
string resolution,
45+
string message,
46+
string errorIconPath,
47+
Func<ActionContext, ValueTask<bool>>? action = null) : base(message)
48+
{
49+
EngineName = engineName;
50+
Resolution = resolution;
51+
ErrorIcon = errorIconPath;
52+
Action = action ?? (_ =>
53+
{
54+
Clipboard.SetDataObject(this.ToString());
55+
return ValueTask.FromResult(true);
56+
});
57+
}
4358

4459
public override string ToString()
4560
{

Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,16 @@ private async ValueTask ThrowIfEverythingNotAvailableAsync(CancellationToken tok
2727
Enum.GetName(Settings.IndexSearchEngineOption.Everything)!,
2828
Main.Context.API.GetTranslation("flowlauncher_plugin_everything_click_to_launch_or_install"),
2929
Main.Context.API.GetTranslation("flowlauncher_plugin_everything_is_not_running"),
30-
ClickToInstallEverythingAsync)
31-
{
32-
ErrorIcon = Constants.EverythingErrorImagePath
33-
};
30+
Constants.EverythingErrorImagePath,
31+
ClickToInstallEverythingAsync);
3432
}
3533
catch (DllNotFoundException)
3634
{
3735
throw new EngineNotAvailableException(
3836
Enum.GetName(Settings.IndexSearchEngineOption.Everything)!,
3937
"Please check whether your system is x86 or x64",
40-
Main.Context.API.GetTranslation("flowlauncher_plugin_everything_sdk_issue"))
41-
{
42-
ErrorIcon = Constants.GeneralSearchErrorImagePath
43-
};
38+
Constants.GeneralSearchErrorImagePath,
39+
Main.Context.API.GetTranslation("flowlauncher_plugin_everything_sdk_issue"));
4440
}
4541
}
4642
private async ValueTask<bool> ClickToInstallEverythingAsync(ActionContext _)
@@ -72,16 +68,14 @@ public async IAsyncEnumerable<SearchResult> ContentSearchAsync(string plainSearc
7268
if (!Settings.EnableEverythingContentSearch)
7369
{
7470
throw new EngineNotAvailableException(Enum.GetName(Settings.IndexSearchEngineOption.Everything)!,
75-
"Click to Enable Everything Content Search (only applicable to Everything 1.5+ with indexed content)",
76-
"Everything Content Search is not enabled.",
71+
Main.Context.API.GetTranslation("flowlauncher_plugin_everything_enable_content_search"),
72+
Main.Context.API.GetTranslation("flowlauncher_plugin_everything_enable_content_search_tips"),
73+
Constants.EverythingErrorImagePath,
7774
_ =>
7875
{
7976
Settings.EnableEverythingContentSearch = true;
8077
return ValueTask.FromResult(true);
81-
})
82-
{
83-
ErrorIcon = Constants.EverythingErrorImagePath
84-
};
78+
});
8579
}
8680
if (token.IsCancellationRequested)
8781
yield break;

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndexSearchManager.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ private IAsyncEnumerable<SearchResult> HandledEngineNotAvailableExceptionAsync()
106106
"Windows Index",
107107
api.GetTranslation("plugin_explorer_windowsSearchServiceFix"),
108108
api.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"),
109+
Constants.WindowsIndexErrorImagePath,
109110
c =>
110111
{
111112
Settings.WarnWindowsSearchServiceOff = false;
@@ -114,10 +115,7 @@ private IAsyncEnumerable<SearchResult> HandledEngineNotAvailableExceptionAsync()
114115
api.ChangeQuery(string.Empty);
115116

116117
return ValueTask.FromResult(false);
117-
})
118-
{
119-
ErrorIcon = Constants.WindowsIndexErrorImagePath
120-
};
118+
});
121119
}
122120
}
123121
}

0 commit comments

Comments
 (0)