diff --git a/src/initialize.cpp b/src/initialize.cpp index 02a4f9ab75..68436f07e4 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -348,14 +348,15 @@ bool read_model_xml() { auto other_inputs = {"materials.xml", "geometry.xml", "settings.xml", "tallies.xml", "plots.xml"}; for (const auto& input : other_inputs) { if (file_exists(settings::path_input + input)) { - warning(("Other XML file input(s) are present. These file will be ignored in favor of the model.xml file.")); + warning((fmt::format("Other XML file input(s) are present. These file will be ignored in favor of the {} file.", xml_filename)); break; } } // Read materials and cross sections if (!check_for_node(root, "materials")) { - fatal_error("No node present in the model.xml file."); + fatal_error( + fmt::format("No node present in the {} file.", xml_filename)); } auto materials_node = root.child("materials"); read_cross_sections_xml(materials_node); @@ -363,7 +364,8 @@ bool read_model_xml() { // Read geometry if (!check_for_node(root, "geometry")) { - fatal_error("No node present in the model.xml_file."); + fatal_error(fmt::format( + "No node present in the model.xml_file.", xml_filename)); } read_geometry_xml(root.child("geometry")); diff --git a/tests/regression_tests/model_xml/test.py b/tests/regression_tests/model_xml/test.py index 342d7dca90..5bfe912a44 100644 --- a/tests/regression_tests/model_xml/test.py +++ b/tests/regression_tests/model_xml/test.py @@ -91,6 +91,7 @@ def test_input_arg(run_in_tmpdir): # run by specifying that single file openmc.run(input_file='pincell.xml') - # now ensure we get an error for an incorrect filename + # now ensure we get an error for an incorrect filename, + # even in the presence of other, valid XML files with pytest.raises(RuntimeError): openmc.run(input_file='ex-em-ell.xml') \ No newline at end of file