@@ -224,6 +224,15 @@ private static Win32 Win32Program(string path)
224
224
225
225
return Default ;
226
226
}
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
227
236
}
228
237
229
238
private static Win32 LnkProgram ( string path )
@@ -270,25 +279,22 @@ private static Win32 LnkProgram(string path)
270
279
"|Error caused likely due to trying to get the description of the program" ,
271
280
e ) ;
272
281
273
- program . Valid = false ;
274
- return program ;
282
+ return Default ;
275
283
}
276
284
catch ( FileNotFoundException e )
277
285
{
278
286
ProgramLogger . LogException ( $ "|Win32|LnkProgram|{ path } " +
279
287
"|An unexpected error occurred in the calling method LnkProgram" , e ) ;
280
288
281
- program . Valid = false ;
282
- return program ;
289
+ return Default ;
283
290
}
284
291
#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.
285
292
catch ( Exception e )
286
293
{
287
294
ProgramLogger . LogException ( $ "|Win32|LnkProgram|{ path } " +
288
295
"|An unexpected error occurred in the calling method LnkProgram" , e ) ;
289
296
290
- program . Valid = false ;
291
- return program ;
297
+ return Default ;
292
298
}
293
299
#endif
294
300
}
@@ -342,6 +348,13 @@ private static Win32 ExeProgram(string path)
342
348
program . Description = info . FileDescription ;
343
349
return program ;
344
350
}
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
+ }
345
358
catch ( Exception e ) when ( e is SecurityException || e is UnauthorizedAccessException )
346
359
{
347
360
ProgramLogger . LogException ( $ "|Win32|ExeProgram|{ path } " +
@@ -386,8 +399,6 @@ private static IEnumerable<Win32> UnregisteredPrograms(List<ProgramSource> sourc
386
399
387
400
// Remove disabled programs in DisabledProgramSources
388
401
var programs = ExceptDisabledSource ( paths ) . Select ( x => GetProgramFromPath ( x , protocols ) ) ;
389
-
390
- . Select ( x => GetProgramFromPath ( x , protocols ) ) ;
391
402
return programs ;
392
403
}
393
404
0 commit comments