From 64bfe718055de8d69510c4c9dc77e4a66e845182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Caux?= Date: Fri, 23 Oct 2026 13:23:31 +0200 Subject: [PATCH] Add exceptions for missing input files --- amplitudes_IDeltax.cc | 6 ++++++ amplitudes_staggered.cc | 6 ++++++ holeIx2.cc | 3 +++ rhoxt.cc | 9 +++++++++ velocity_lifetime.cc | 9 +++++++++ 5 files changed, 33 insertions(+) diff --git a/amplitudes_IDeltax.cc b/amplitudes_IDeltax.cc index 5945cad..88195b8 100644 --- a/amplitudes_IDeltax.cc +++ b/amplitudes_IDeltax.cc @@ -97,12 +97,18 @@ int main(int argc, char* argv[]) states_filename << filename_base.str() << ".states"; std::ifstream states_file; states_file.open(states_filename.str()); + if (states_file.fail()) { + throw AbacusException("Cound not open the states file " + states_filename.str()); + } states_file >> std::setprecision(std::numeric_limits::digits10 + 1); std::stringstream rho_ME_filename; rho_ME_filename << filename_base.str() << ".rho"; std::ifstream rho_ME_file; rho_ME_file.open(rho_ME_filename.str()); + if (rho_ME_file.fail()) { + throw AbacusException("Cound not open the rho file " + rho_ME_filename.str()); + } rho_ME_file >> std::setprecision(std::numeric_limits::digits10 + 1); diff --git a/amplitudes_staggered.cc b/amplitudes_staggered.cc index 422353a..2525e37 100644 --- a/amplitudes_staggered.cc +++ b/amplitudes_staggered.cc @@ -93,12 +93,18 @@ int main(int argc, char* argv[]) states_filename << filename_base.str() << ".states"; std::ifstream states_file; states_file.open(states_filename.str()); + if (states_file.fail()) { + throw AbacusException("Cound not open the states file " + states_filename.str()); + } states_file >> std::setprecision(std::numeric_limits::digits10 + 1); std::stringstream rho_ME_filename; rho_ME_filename << filename_base.str() << ".rho"; std::ifstream rho_ME_file; rho_ME_file.open(rho_ME_filename.str()); + if (rho_ME_file.fail()) { + throw AbacusException("Cound not open the rho file " + rho_ME_filename.str()); + } rho_ME_file >> std::setprecision(std::numeric_limits::digits10 + 1); diff --git a/holeIx2.cc b/holeIx2.cc index 929efdf..d23e8f0 100644 --- a/holeIx2.cc +++ b/holeIx2.cc @@ -91,6 +91,9 @@ int main(int argc, char* argv[]) states_filename << filename_base.str() << ".states"; std::ifstream states_file; states_file.open(states_filename.str()); + if (states_file.fail()) { + throw AbacusException("Cound not open the states file " + states_filename.str()); + } states_file >> std::setprecision(std::numeric_limits::digits10 + 1); std::stringstream holeIx2_filename; diff --git a/rhoxt.cc b/rhoxt.cc index cb32414..2e4978c 100644 --- a/rhoxt.cc +++ b/rhoxt.cc @@ -91,18 +91,27 @@ void Orchestrator::set_up() states_filename << filename_base.str() << ".states"; std::ifstream states_file; states_file.open(states_filename.str()); + if (states_file.fail()) { + throw AbacusException("Cound not open the states file " + states_filename.str()); + } states_file >> std::setprecision(std::numeric_limits::digits10 + 1); std::stringstream amplitudes_filename; amplitudes_filename << filename_base.str() << "_" << protocol_ << ".amplitudes"; std::ifstream amplitudes_file; amplitudes_file.open(amplitudes_filename.str()); + if (amplitudes_file.fail()) { + throw AbacusException("Cound not open the amplitudes file " + amplitudes_filename.str()); + } amplitudes_file >> std::setprecision(std::numeric_limits::digits10 + 1); std::stringstream rho_ME_filename; rho_ME_filename << filename_base.str() << ".rho"; std::ifstream rho_ME_file; rho_ME_file.open(rho_ME_filename.str()); + if (rho_ME_file.fail()) { + throw AbacusException("Cound not open the rho file " + rho_ME_filename.str()); + } rho_ME_file >> std::setprecision(std::numeric_limits::digits10 + 1); diff --git a/velocity_lifetime.cc b/velocity_lifetime.cc index b13cd54..960dc13 100644 --- a/velocity_lifetime.cc +++ b/velocity_lifetime.cc @@ -104,18 +104,27 @@ int main(int argc, char* argv[]) states_filename << filename_base.str() << ".states"; std::ifstream states_file; states_file.open(states_filename.str()); + if (states_file.fail()) { + throw AbacusException("Cound not open the states file " + states_filename.str()); + } states_file >> std::setprecision(std::numeric_limits::digits10 + 1); std::stringstream amplitudes_filename; amplitudes_filename << filename_base.str() << "_" << protocol_ << ".amplitudes"; std::ifstream amplitudes_file; amplitudes_file.open(amplitudes_filename.str()); + if (amplitudes_file.fail()) { + throw AbacusException("Cound not open the amplitudes file " + amplitudes_filename.str()); + } amplitudes_file >> std::setprecision(std::numeric_limits::digits10 + 1); std::stringstream rho_ME_filename; rho_ME_filename << filename_base.str() << ".rho"; std::ifstream rho_ME_file; rho_ME_file.open(rho_ME_filename.str()); + if (rho_ME_file.fail()) { + throw AbacusException("Cound not open the rho file " + rho_ME_filename.str()); + } rho_ME_file >> std::setprecision(std::numeric_limits::digits10 + 1);