From 57f773ff5808fabde350f8d12baeca9ba72f2062 Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Tue, 25 Feb 2020 13:46:46 +0100
Subject: [PATCH] [TracerRealTime] Check that output file is valid.

---
 src/traces/tracer-real-time.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/traces/tracer-real-time.cpp b/src/traces/tracer-real-time.cpp
index e2fdcbe..9084424 100644
--- a/src/traces/tracer-real-time.cpp
+++ b/src/traces/tracer-real-time.cpp
@@ -125,6 +125,11 @@ void TracerRealTime::openFile(const SignalBase<int> &sig,
   string filename = rootdir + basename + signame + suffix;
   dgDEBUG(5) << "Sig <" << sig.getName() << ">: new file " << filename << endl;
   std::ofstream *newfile = new std::ofstream(filename.c_str());
+  if (!newfile->good()) {
+    delete newfile;
+    DG_THROW ExceptionTraces(ExceptionTraces::NOT_OPEN,
+        "Could not open file " + filename + " for signal " + signame, "");
+  }
   dgDEBUG(5) << "Newfile:" << (void *)newfile << endl;
   hardFiles.push_back(newfile);
   dgDEBUG(5) << "Creating Outstringstream" << endl;
@@ -264,7 +269,7 @@ void TracerRealTime::recordSignal(std::ostream &os,
                 << "> " << endl;
 
   } catch (ExceptionAbstract &exc) {
-    throw exc;
+    throw;
   } catch (...) {
     DG_THROW ExceptionTraces(ExceptionTraces::NOT_OPEN,
                              "The buffer is not open", "");
-- 
GitLab