Skip to content

Commit 519702c

Browse files
handing exception
1 parent 3347e9f commit 519702c

File tree

1 file changed

+19
-8
lines changed
  • Plugins/Flow.Launcher.Plugin.Program/Programs

1 file changed

+19
-8
lines changed

Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,15 @@ private static Win32 Win32Program(string path)
224224

225225
return Default;
226226
}
227+
#if !DEBUG
228+
catch (Exception e)
229+
{
230+
ProgramLogger.LogException($"|Win32|Win32Program|{path}" +
231+
"|An unexpected error occurred in the calling method Win32Program", e);
232+
233+
return Default;
234+
}
235+
#endif
227236
}
228237

229238
private static Win32 LnkProgram(string path)
@@ -270,25 +279,22 @@ private static Win32 LnkProgram(string path)
270279
"|Error caused likely due to trying to get the description of the program",
271280
e);
272281

273-
program.Valid = false;
274-
return program;
282+
return Default;
275283
}
276284
catch (FileNotFoundException e)
277285
{
278286
ProgramLogger.LogException($"|Win32|LnkProgram|{path}" +
279287
"|An unexpected error occurred in the calling method LnkProgram", e);
280288

281-
program.Valid = false;
282-
return program;
289+
return Default;
283290
}
284291
#if !DEBUG //Only do a catch all in production. This is so make developer aware of any unhandled exception and add the exception handling in.
285292
catch (Exception e)
286293
{
287294
ProgramLogger.LogException($"|Win32|LnkProgram|{path}" +
288295
"|An unexpected error occurred in the calling method LnkProgram", e);
289296

290-
program.Valid = false;
291-
return program;
297+
return Default;
292298
}
293299
#endif
294300
}
@@ -342,6 +348,13 @@ private static Win32 ExeProgram(string path)
342348
program.Description = info.FileDescription;
343349
return program;
344350
}
351+
catch (FileNotFoundException e)
352+
{
353+
ProgramLogger.LogException($"|Win32|ExeProgram|{path}" +
354+
$"|File not found when trying to load the program from {path}", e);
355+
356+
return Default;
357+
}
345358
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
346359
{
347360
ProgramLogger.LogException($"|Win32|ExeProgram|{path}" +
@@ -386,8 +399,6 @@ private static IEnumerable<Win32> UnregisteredPrograms(List<ProgramSource> sourc
386399

387400
// Remove disabled programs in DisabledProgramSources
388401
var programs = ExceptDisabledSource(paths).Select(x => GetProgramFromPath(x, protocols));
389-
390-
.Select(x => GetProgramFromPath(x, protocols));
391402
return programs;
392403
}
393404

0 commit comments

Comments
 (0)