@@ -25,7 +25,7 @@ public class Program
2525 public static Dictionary < string , IFileJob > Jobs = new Dictionary < string , IFileJob > ( ) ;
2626 public static void Main ( string [ ] args )
2727 {
28- ConfigureLogger ( args . FirstOrDefault ( ) ) ;
28+ ConfigureLogger ( args ? . FirstOrDefault ( ) ) ;
2929 log = LoggerFactory . CreateLogger ( "FileSyncAppMain" ) ;
3030 if ( null != args && args . Length > 0 )
3131 {
@@ -50,6 +50,7 @@ static void RunProgram()
5050 ContractResolver = new IgnorePropertyResolver ( new string [ ] { "Logger" } ) ,
5151 TypeNameHandling = TypeNameHandling . Auto ,
5252 } ;
53+
5354 if ( ! File . Exists ( "config.json" ) )
5455 {
5556 log . LogInformation ( "Config file {A} not found, creating a new one" , "config.json" ) ;
@@ -96,10 +97,19 @@ static void RunProgram()
9697 var json = JsonConvert . SerializeObject ( jobOptions , Formatting . Indented , jsonSettings ) ;
9798 File . WriteAllText ( "config.json" , json ) ;
9899 }
99- log . LogInformation ( "reading config file {A}" , "config.json" ) ;
100- var readJobOptions = JsonConvert . DeserializeObject < Dictionary < string , IFileJobOptions > > ( File . ReadAllText ( "config.json" ) , jsonSettings ) ;
101- //List<IFileJob> Jobs = new List<IFileJob>();
102100
101+ log . LogInformation ( "reading config file {A}" , "config.json" ) ;
102+ Dictionary < string , IFileJobOptions > readJobOptions = new Dictionary < string , IFileJobOptions > ( ) ;
103+ try
104+ {
105+ readJobOptions = JsonConvert . DeserializeObject < Dictionary < string , IFileJobOptions > > ( File . ReadAllText ( "config.json" ) , jsonSettings ) ;
106+ }
107+ catch ( Exception exc )
108+ {
109+ log . LogCritical ( exc , "exception reading config file {A}" , "config.json" ) ;
110+ return ;
111+ }
112+
103113 foreach ( var jobOption in readJobOptions )
104114 {
105115
0 commit comments