From 5d435d396cd58a52d903ec91f77c9011a35018c2 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Mon, 2 Sep 2013 17:35:33 +0200 Subject: [PATCH] catch all exceptions in all tutorials and examples --- examples/compute_tof.cpp | 5 +++++ examples/compute_tof_from_files.cpp | 5 +++++ examples/import_rewrite.cpp | 5 +++++ examples/sim_2p_comp_reorder.cpp | 5 +++++ examples/sim_2p_incomp.cpp | 5 +++++ examples/wells_example.cpp | 7 +++++-- tutorials/tutorial1.cpp | 5 +++++ tutorials/tutorial2.cpp | 5 +++++ tutorials/tutorial3.cpp | 5 +++++ tutorials/tutorial4.cpp | 6 ++++++ 10 files changed, 51 insertions(+), 2 deletions(-) diff --git a/examples/compute_tof.cpp b/examples/compute_tof.cpp index 050ec301..2db691d8 100644 --- a/examples/compute_tof.cpp +++ b/examples/compute_tof.cpp @@ -92,6 +92,7 @@ namespace // ----------------- Main program ----------------- int main(int argc, char** argv) +try { using namespace Opm; @@ -297,3 +298,7 @@ main(int argc, char** argv) << "\n Pressure time: " << ptime << "\n Transport time: " << ttime << std::endl; } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} diff --git a/examples/compute_tof_from_files.cpp b/examples/compute_tof_from_files.cpp index bc4398d8..29787139 100644 --- a/examples/compute_tof_from_files.cpp +++ b/examples/compute_tof_from_files.cpp @@ -73,6 +73,7 @@ namespace // ----------------- Main program ----------------- int main(int argc, char** argv) +try { using namespace Opm; @@ -209,3 +210,7 @@ main(int argc, char** argv) } } } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} diff --git a/examples/import_rewrite.cpp b/examples/import_rewrite.cpp index 280c3ab1..37fe1004 100644 --- a/examples/import_rewrite.cpp +++ b/examples/import_rewrite.cpp @@ -250,6 +250,7 @@ static bool parseFile(const std::string& inputFile, std::string& outputFile, con int main(int argc, char** argv) +try { if (argc != 2) OPM_THROW(std::runtime_error, "Need the name of ECLIPSE file on command line"); @@ -258,3 +259,7 @@ main(int argc, char** argv) parseFile(argv[1] , outputFile); } } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} diff --git a/examples/sim_2p_comp_reorder.cpp b/examples/sim_2p_comp_reorder.cpp index 9445563c..18077859 100644 --- a/examples/sim_2p_comp_reorder.cpp +++ b/examples/sim_2p_comp_reorder.cpp @@ -70,6 +70,7 @@ namespace // ----------------- Main program ----------------- int main(int argc, char** argv) +try { using namespace Opm; @@ -282,3 +283,7 @@ main(int argc, char** argv) } } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} diff --git a/examples/sim_2p_incomp.cpp b/examples/sim_2p_incomp.cpp index ea9d11fb..68791092 100644 --- a/examples/sim_2p_incomp.cpp +++ b/examples/sim_2p_incomp.cpp @@ -71,6 +71,7 @@ namespace // ----------------- Main program ----------------- int main(int argc, char** argv) +try { using namespace Opm; @@ -300,3 +301,7 @@ main(int argc, char** argv) } } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} diff --git a/examples/wells_example.cpp b/examples/wells_example.cpp index f074fc69..2a252338 100644 --- a/examples/wells_example.cpp +++ b/examples/wells_example.cpp @@ -20,8 +20,8 @@ #include int main(int argc, char** argv) +try { - using namespace Opm::parameter; using namespace Opm; ParameterGroup parameters(argc, argv, false); @@ -130,4 +130,7 @@ int main(int argc, char** argv) #endif return 0; } - +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} diff --git a/tutorials/tutorial1.cpp b/tutorials/tutorial1.cpp index 878c0c69..917778e9 100644 --- a/tutorials/tutorial1.cpp +++ b/tutorials/tutorial1.cpp @@ -45,6 +45,7 @@ // ----------------- Main program ----------------- int main() +try { /// \page tutorial1 /// We set the number of blocks in each direction. @@ -102,6 +103,10 @@ int main() /// \internal [write vtk] /// \endinternal } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} /// \page tutorial1 /// We read the vtu output file in \a Paraview and obtain the following grid. diff --git a/tutorials/tutorial2.cpp b/tutorials/tutorial2.cpp index ac8845bc..ad606da0 100644 --- a/tutorials/tutorial2.cpp +++ b/tutorials/tutorial2.cpp @@ -50,6 +50,7 @@ /// int main() +try { /// \page tutorial2 @@ -195,6 +196,10 @@ int main() /// \internal [write output] /// \endinternal } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} /// \page tutorial2 /// We read the vtu output file in \a Paraview and obtain the following pressure diff --git a/tutorials/tutorial3.cpp b/tutorials/tutorial3.cpp index 9a24d2d8..d3e5e5f6 100644 --- a/tutorials/tutorial3.cpp +++ b/tutorials/tutorial3.cpp @@ -93,6 +93,7 @@ /// \snippet tutorial3.cpp main /// \internal [main] int main () +try { /// \internal [main] /// \endinternal @@ -316,6 +317,10 @@ int main () Opm::writeVtkData(grid, dm, vtkfile); } } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} /// \internal [write output] /// \endinternal diff --git a/tutorials/tutorial4.cpp b/tutorials/tutorial4.cpp index 902effde..40ea6016 100644 --- a/tutorials/tutorial4.cpp +++ b/tutorials/tutorial4.cpp @@ -52,6 +52,7 @@ /// \snippet tutorial4.cpp main /// \internal[main] int main () +try { /// \internal[main] /// \endinternal @@ -436,6 +437,11 @@ int main () destroy_wells(wells); } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} + /// \internal[write output] /// \endinternal