@@ -98,7 +98,7 @@ private static Configuration loadConfiguration(String[] args) throws InvalidConf
9898 }
9999
100100
101- public static void main (String [] args ) throws Exception {
101+ public static void main (String [] args ) {
102102
103103 initGitInfo ();
104104
@@ -109,17 +109,30 @@ public static void main(String[] args) throws Exception {
109109
110110 if (Arrays .asList (args ).contains ("--version" )) {
111111 final MavenXpp3Reader mvnReader = new MavenXpp3Reader ();
112- final FileReader fileReader = new FileReader (System .getenv ("DAT3M_HOME" ) + "/pom.xml" );
113- final String base = mvnReader .read (fileReader ).getVersion ();
114- final String version = base .equals (getGitTags ()) ? base : String .format ("%s (commit %s)" , base , getGitId ());
115- System .out .println (version );
112+ final String pomPath = System .getenv ("DAT3M_HOME" ) + "/pom.xml" ;
113+ try (FileReader fileReader = new FileReader (pomPath )) {
114+ final String base = mvnReader .read (fileReader ).getVersion ();
115+ final String version = base .equals (getGitTags ()) ? base : String .format ("%s (commit %s)" , base , getGitId ());
116+ System .out .println (version );
117+ } catch (Exception e ) {
118+ logger .warn ("Failed to read version from {}" , pomPath , e );
119+ System .exit (UNKNOWN_ERROR .asInt ());
120+ }
116121 return ;
117122 }
118123
119124 logGitInfo ();
120125
121- final Configuration config = loadConfiguration (args );
122- final Dartagnan o = new Dartagnan (config );
126+ final Configuration config ;
127+ final Dartagnan o ;
128+ try {
129+ config = loadConfiguration (args );
130+ o = new Dartagnan (config );
131+ } catch (IOException | InvalidConfigurationException e ) {
132+ logger .error (e .getMessage ());
133+ System .exit (UNKNOWN_ERROR .asInt ());
134+ return ;
135+ }
123136
124137 final File fileModel = new File (Arrays .stream (args ).filter (a -> a .endsWith (".cat" )).findFirst ()
125138 .orElseThrow (() -> new IllegalArgumentException ("CAT model not given or format not recognized" )));
@@ -129,7 +142,13 @@ public static void main(String[] args) throws Exception {
129142 final WitnessGraph witness ;
130143 if (o .runValidator ()) {
131144 logger .info ("Witness path: {}" , o .getWitnessPath ());
132- witness = new ParserWitness ().parse (new File (o .getWitnessPath ()));
145+ try {
146+ witness = new ParserWitness ().parse (new File (o .getWitnessPath ()));
147+ } catch (IOException e ) {
148+ logger .error ("Failed to read witness file {}" , o .getWitnessPath ());
149+ System .exit (WRONG_WITNESS_FILE .asInt ());
150+ return ;
151+ }
133152 } else {
134153 witness = new WitnessGraph ();
135154 }
@@ -220,7 +239,9 @@ private static List<File> getProgramFilesFromArgs(String[] args) {
220239 }
221240 });
222241 if (files .isEmpty ()) {
223- throw new IllegalArgumentException ("Path to input program(s) not given or format not recognized" );
242+ logger .error ("Path to input program(s) not given or format not recognized" );
243+ System .exit (UNKNOWN_ERROR .asInt ());
244+
224245 }
225246 return files ;
226247 }
0 commit comments