File tree 2 files changed +7
-0
lines changed
fed/mosaic-output/src/main/java/org/eclipse/mosaic/fed/output/ambassador
lib/mosaic-utils/src/main/java/org/eclipse/mosaic/lib/util
2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change 35
35
import org .slf4j .LoggerFactory ;
36
36
37
37
import java .io .IOException ;
38
+ import java .io .FileNotFoundException ;
38
39
import java .util .Collection ;
39
40
import java .util .HashMap ;
40
41
import java .util .List ;
@@ -154,6 +155,8 @@ private Collection<OutputGeneratorLoader> loadConfiguration() {
154
155
155
156
// do not yet create output generators. This is done when the ambassadors initialize method is called
156
157
return generatorLoader .values ();
158
+ } catch (FileNotFoundException e ) {
159
+ throw new RuntimeException ("Configuration file not found. Consider turning off the output ambassador in scenario_config.json" , e );
157
160
} catch (InternalFederateException | IllegalArgumentException | IllegalStateException | IOException e ) {
158
161
throw new RuntimeException (e );
159
162
} catch (Exception ex ) {
Original file line number Diff line number Diff line change 24
24
import org .apache .commons .lang3 .ObjectUtils ;
25
25
26
26
import java .io .File ;
27
+ import java .io .FileNotFoundException ;
27
28
import java .io .IOException ;
28
29
import java .io .InputStream ;
29
30
import java .util .stream .Collectors ;
@@ -53,6 +54,9 @@ protected Transformer createTransformer() throws ConfigurationException {
53
54
}
54
55
55
56
public static XMLConfiguration readXmlFromFile (File file ) throws IOException {
57
+ if (!file .exists () || !file .isFile ()) {
58
+ throw new FileNotFoundException (file .getAbsolutePath () + " cannot be found" );
59
+ }
56
60
final XMLConfiguration configuration = createEmptyConfigurationWithIndentation (DEFAULT_XML_INDENTATION );
57
61
try {
58
62
new FileHandler (configuration ).load (file );
You can’t perform that action at this time.
0 commit comments