Skip to content

Commit eef1dcc

Browse files
committed
fix: crash while reading JetBrains Toolbox's state.json (#1999)
Signed-off-by: leo <[email protected]>
1 parent 50f8e0c commit eef1dcc

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/Models/ExternalTool.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,24 @@ public void FindJetBrainsFromToolbox(Func<string> platformFinder)
180180
var state = Path.Combine(platformFinder(), "state.json");
181181
if (File.Exists(state))
182182
{
183-
using var stream = File.OpenRead(state);
184-
var stateData = JsonSerializer.Deserialize(stream, JsonCodeGen.Default.JetBrainsState);
185-
foreach (var tool in stateData.Tools)
183+
try
186184
{
187-
if (exclude.Contains(tool.ToolId.ToLowerInvariant()))
188-
continue;
189-
190-
Tools.Add(new ExternalTool(
191-
$"{tool.DisplayName} {tool.DisplayVersion}",
192-
supportedIcons.Contains(tool.ProductCode) ? $"JetBrains/{tool.ProductCode}" : "JetBrains/JB",
193-
Path.Combine(tool.InstallLocation, tool.LaunchCommand)));
185+
using var stream = File.OpenRead(state);
186+
var stateData = JsonSerializer.Deserialize(stream, JsonCodeGen.Default.JetBrainsState);
187+
foreach (var tool in stateData.Tools)
188+
{
189+
if (exclude.Contains(tool.ToolId.ToLowerInvariant()))
190+
continue;
191+
192+
Tools.Add(new ExternalTool(
193+
$"{tool.DisplayName} {tool.DisplayVersion}",
194+
supportedIcons.Contains(tool.ProductCode) ? $"JetBrains/{tool.ProductCode}" : "JetBrains/JB",
195+
Path.Combine(tool.InstallLocation, tool.LaunchCommand)));
196+
}
197+
}
198+
catch
199+
{
200+
// Ignore exceptions.
194201
}
195202
}
196203
}

0 commit comments

Comments
 (0)