Skip to content

Commit 2f9c101

Browse files
authored
Merge pull request #3900 from Flow-Launcher/environment_install
Add error handler for DroplexPackage.Drop
2 parents ebdea4f + 4cbc9f1 commit 2f9c101

File tree

4 files changed

+49
-6
lines changed

4 files changed

+49
-6
lines changed

Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
1111
{
1212
internal class PythonEnvironment : AbstractPluginEnvironment
1313
{
14+
private static readonly string ClassName = nameof(PythonEnvironment);
15+
1416
internal override string Language => AllowedLanguage.Python;
1517

1618
internal override string EnvName => DataLocation.PythonEnvironmentName;
@@ -39,9 +41,20 @@ internal override void InstallEnvironment()
3941

4042
// Python 3.11.4 is no longer Windows 7 compatible. If user is on Win 7 and
4143
// uses Python plugin they need to custom install and use v3.8.9
42-
JTF.Run(() => DroplexPackage.Drop(App.python_3_11_4_embeddable, InstallPath));
44+
JTF.Run(async () =>
45+
{
46+
try
47+
{
48+
await DroplexPackage.Drop(App.python_3_11_4_embeddable, InstallPath);
4349

44-
PluginsSettingsFilePath = ExecutablePath;
50+
PluginsSettingsFilePath = ExecutablePath;
51+
}
52+
catch (System.Exception e)
53+
{
54+
API.ShowMsgError(API.GetTranslation("failToInstallPythonEnv"));
55+
API.LogException(ClassName, "Failed to install Python environment", e);
56+
}
57+
});
4558
}
4659

4760
internal override PluginPair CreatePluginPair(string filePath, PluginMetadata metadata)

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
1111
{
1212
internal class TypeScriptEnvironment : AbstractPluginEnvironment
1313
{
14+
private static readonly string ClassName = nameof(TypeScriptEnvironment);
15+
1416
internal override string Language => AllowedLanguage.TypeScript;
1517

1618
internal override string EnvName => DataLocation.NodeEnvironmentName;
@@ -34,9 +36,20 @@ internal override void InstallEnvironment()
3436
{
3537
FilesFolders.RemoveFolderIfExists(InstallPath, (s) => API.ShowMsgBox(s));
3638

37-
JTF.Run(() => DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath));
39+
JTF.Run(async () =>
40+
{
41+
try
42+
{
43+
await DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath);
3844

39-
PluginsSettingsFilePath = ExecutablePath;
45+
PluginsSettingsFilePath = ExecutablePath;
46+
}
47+
catch (System.Exception e)
48+
{
49+
API.ShowMsgError(API.GetTranslation("failToInstallTypeScriptEnv"));
50+
API.LogException(ClassName, "Failed to install TypeScript environment", e);
51+
}
52+
});
4053
}
4154

4255
internal override PluginPair CreatePluginPair(string filePath, PluginMetadata metadata)

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
1111
{
1212
internal class TypeScriptV2Environment : AbstractPluginEnvironment
1313
{
14+
private static readonly string ClassName = nameof(TypeScriptV2Environment);
15+
1416
internal override string Language => AllowedLanguage.TypeScriptV2;
1517

1618
internal override string EnvName => DataLocation.NodeEnvironmentName;
@@ -34,9 +36,20 @@ internal override void InstallEnvironment()
3436
{
3537
FilesFolders.RemoveFolderIfExists(InstallPath, (s) => API.ShowMsgBox(s));
3638

37-
JTF.Run(() => DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath));
39+
JTF.Run(async () =>
40+
{
41+
try
42+
{
43+
await DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath);
3844

39-
PluginsSettingsFilePath = ExecutablePath;
45+
PluginsSettingsFilePath = ExecutablePath;
46+
}
47+
catch (System.Exception e)
48+
{
49+
API.ShowMsgError(API.GetTranslation("failToInstallTypeScriptEnv"));
50+
API.LogException(ClassName, "Failed to install TypeScript environment", e);
51+
}
52+
});
4053
}
4154

4255
internal override PluginPair CreatePluginPair(string filePath, PluginMetadata metadata)

Flow.Launcher/Languages/en.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
<system:String x:Key="pleaseTryAgain">Please try again</system:String>
3535
<system:String x:Key="parseProxyFailed">Unable to parse Http Proxy</system:String>
3636

37+
<!-- AbstractPluginEnvironment -->
38+
<system:String x:Key="failToInstallTypeScriptEnv">Failed to install TypeScript environment. Please try again later</system:String>
39+
<system:String x:Key="failToInstallPythonEnv">Failed to install Python environment. Please try again later.</system:String>
40+
3741
<!-- MainWindow -->
3842
<system:String x:Key="registerHotkeyFailed">Failed to register hotkey "{0}". The hotkey may be in use by another program. Change to a different hotkey, or exit another program.</system:String>
3943
<system:String x:Key="unregisterHotkeyFailed">Failed to unregister hotkey "{0}". Please try again or see log for details</system:String>

0 commit comments

Comments
 (0)