]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Improve exception handling in two tutorials. 4071/head
authorDavid Wells <wellsd2@rpi.edu>
Fri, 17 Mar 2017 00:38:43 +0000 (20:38 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Fri, 17 Mar 2017 00:38:43 +0000 (20:38 -0400)
These were caught by Coverity.

examples/step-49/step-49.cc
examples/step-50/step-50.cc

index eeeb60cd3797838bf9c018bfe23d36feeb96cdc7..b884ea8c6c55f986aa3c7b71a5517c453072f829 100644 (file)
@@ -350,11 +350,38 @@ void grid_7()
 // subfunctions.
 int main ()
 {
-  grid_1 ();
-  grid_2 ();
-  grid_3 ();
-  grid_4 ();
-  grid_5 ();
-  grid_6 ();
-  grid_7 ();
+  try
+    {
+      grid_1 ();
+      grid_2 ();
+      grid_3 ();
+      grid_4 ();
+      grid_5 ();
+      grid_6 ();
+      grid_7 ();
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    }
 }
index bff72b20186e1421b2f207443ff7b533b0f587e1..69119e34ba466234a3667455798e6d70f91a6535 100644 (file)
@@ -989,7 +989,6 @@ int main (int argc, char *argv[])
                 << "Aborting!" << std::endl
                 << "----------------------------------------------------"
                 << std::endl;
-      throw;
     }
   catch (...)
     {

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.