From de5faae6c99a9e24a730c96668f81cac13883a90 Mon Sep 17 00:00:00 2001
From: Ger van Diepen <diepen@astron.nl>
Date: Thu, 21 Apr 2011 12:01:06 +0000
Subject: [PATCH] bug 1655: Use backtrace possibility

---
 CEP/MS/src/combinevds.cc |  7 +++++--
 CEP/MS/src/makevds.cc    | 10 +++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/CEP/MS/src/combinevds.cc b/CEP/MS/src/combinevds.cc
index 41d90406384..1a9676d7c97 100644
--- a/CEP/MS/src/combinevds.cc
+++ b/CEP/MS/src/combinevds.cc
@@ -30,6 +30,9 @@ using namespace std;
 using namespace LOFAR;
 using namespace LOFAR::CEP;
 
+// Define handler that tries to print a backtrace.
+Exception::TerminateHandler t(Exception::terminate);
+
 int main (int argc, const char* argv[])
 {
   try {
@@ -46,8 +49,8 @@ int main (int argc, const char* argv[])
     // Combine them.
     VdsMaker::combine (argv[1], vdsNames);
 
-  } catch (exception& x) {
-    cout << "Unexpected expection: " << x.what() << endl;
+  } catch (LOFAR::Exception& err) {
+    std::cerr << "LOFAR Exception detected: " << err << std::endl;
     return 1;
   }
   return 0;
diff --git a/CEP/MS/src/makevds.cc b/CEP/MS/src/makevds.cc
index 818985ad691..a6157e4b7c0 100644
--- a/CEP/MS/src/makevds.cc
+++ b/CEP/MS/src/makevds.cc
@@ -25,14 +25,18 @@
 #include<stdexcept>
 #include <iostream>
 
+using namespace LOFAR;
 using namespace std;
 
+// Define handler that tries to print a backtrace.
+Exception::TerminateHandler t(Exception::terminate);
 
 int main(int argc, const char* argv[])
 {
   try {
     if (argc < 3  ||  argv[1][0] == '\0'  ||  argv[2][0] == '\0') {
-      cout << "Run as:  makevds clusterdesc ms [msvds] [hostname] [writetimes]" << endl;
+      cout << "Run as:  makevds clusterdesc ms [msvds] [hostname] [writetimes]"
+           << endl;
       cout << "  default vds name is <ms>.vds" << endl;
       cout << "  default host name is gethostname()" << endl;
       cout << "  default writetimes is false (0)" << endl;
@@ -58,8 +62,8 @@ int main(int argc, const char* argv[])
       writeTimes = (argv[5][0]=='t' || argv[5][0]=='T' || argv[5][0]=='1');
     }
     LOFAR::VdsMaker::create (argv[2], msvds, argv[1], hostName, writeTimes);
-  } catch (exception& x) {
-    cout << "Unexpected expection: " << x.what() << endl;
+  } catch (LOFAR::Exception& err) {
+    std::cerr << "LOFAR Exception detected: " << err << std::endl;
     return 1;
   }
   return 0;
-- 
GitLab