diff --git a/examples/flow.cpp b/examples/flow.cpp index 196844d8b..45a7b0e91 100644 --- a/examples/flow.cpp +++ b/examples/flow.cpp @@ -63,6 +63,7 @@ #include #include #include +#include namespace @@ -101,7 +102,8 @@ try parameter::ParameterGroup param(argc, argv, false); if (!param.unhandledArguments().empty()) { if (param.unhandledArguments().size() != 1) { - OPM_THROW(std::runtime_error, "You can only specify a single input deck on the command line."); + std::cerr << "You can only specify a single input deck on the command line.\n"; + return EXIT_FAILURE; } else { param.insertParameter("deck_filename", param.unhandledArguments()[0]); } @@ -113,8 +115,8 @@ try "Specify the deck filename either\n" " a) as a command line argument by itself\n" " b) as a command line parameter with the syntax deck_filename=, or\n" - " c) as a parameter in a parameter file (.param or .xml) passed to the program."; - OPM_THROW(std::runtime_error, "Input deck required."); + " c) as a parameter in a parameter file (.param or .xml) passed to the program.\n"; + return EXIT_FAILURE; } std::shared_ptr grid; std::shared_ptr props; @@ -138,7 +140,8 @@ try create_directories(fpath); } catch (...) { - OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); + std::cerr << "Creating directories failed: " << fpath << std::endl; + return EXIT_FAILURE; } // Write simulation parameters. param.writeParam(output_dir + "/simulation.param"); @@ -280,6 +283,6 @@ try } catch (const std::exception &e) { std::cerr << "Program threw an exception: " << e.what() << "\n"; - throw; + return EXIT_FAILURE; } diff --git a/examples/flow_cp.cpp b/examples/flow_cp.cpp index 79d66468a..6e8c1714b 100644 --- a/examples/flow_cp.cpp +++ b/examples/flow_cp.cpp @@ -89,6 +89,7 @@ #include #include #include +#include namespace { @@ -128,7 +129,8 @@ try parameter::ParameterGroup param(argc, argv, false); if (!param.unhandledArguments().empty()) { if (param.unhandledArguments().size() != 1) { - OPM_THROW(std::runtime_error, "You can only specify a single input deck on the command line."); + std::cerr << "You can only specify a single input deck on the command line.\n"; + return EXIT_FAILURE; } else { param.insertParameter("deck_filename", param.unhandledArguments()[0]); } @@ -140,8 +142,8 @@ try "Specify the deck filename either\n" " a) as a command line argument by itself\n" " b) as a command line parameter with the syntax deck_filename=, or\n" - " c) as a parameter in a parameter file (.param or .xml) passed to the program."; - OPM_THROW(std::runtime_error, "Input deck required."); + " c) as a parameter in a parameter file (.param or .xml) passed to the program.\n"; + return EXIT_FAILURE; } std::shared_ptr grid; std::shared_ptr props; @@ -165,7 +167,8 @@ try create_directories(fpath); } catch (...) { - OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); + std::cerr << "Creating directories failed: " << fpath << std::endl; + return EXIT_FAILURE; } // Write simulation parameters. param.writeParam(output_dir + "/simulation.param"); @@ -271,9 +274,10 @@ try { if( param.getDefault("output_matlab", false) || param.getDefault("output_ecl", true) ) { - OPM_THROW(std::logic_error, "We only support vtk output during parallel runs. " - <<"Please use \"output_matlab=false output_ecl=false\" to deactivate the " - <<"other outputs!"); + std::cerr << "We only support vtk output during parallel runs. \n" + << "Please use \"output_matlab=false output_ecl=false\" to deactivate the \n" + << "other outputs!" << std::endl; + return EXIT_FAILURE; } grid->loadBalance(); Dune::CpGrid global_grid = *grid; @@ -359,6 +363,6 @@ try } catch (const std::exception &e) { std::cerr << "Program threw an exception: " << e.what() << "\n"; - throw; + return EXIT_FAILURE; }