Skip to content

Commit 57f773f

Browse files
committed
[TracerRealTime] Check that output file is valid.
1 parent e34bd06 commit 57f773f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/traces/tracer-real-time.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ void TracerRealTime::openFile(const SignalBase<int> &sig,
125125
string filename = rootdir + basename + signame + suffix;
126126
dgDEBUG(5) << "Sig <" << sig.getName() << ">: new file " << filename << endl;
127127
std::ofstream *newfile = new std::ofstream(filename.c_str());
128+
if (!newfile->good()) {
129+
delete newfile;
130+
DG_THROW ExceptionTraces(ExceptionTraces::NOT_OPEN,
131+
"Could not open file " + filename + " for signal " + signame, "");
132+
}
128133
dgDEBUG(5) << "Newfile:" << (void *)newfile << endl;
129134
hardFiles.push_back(newfile);
130135
dgDEBUG(5) << "Creating Outstringstream" << endl;
@@ -264,7 +269,7 @@ void TracerRealTime::recordSignal(std::ostream &os,
264269
<< "> " << endl;
265270

266271
} catch (ExceptionAbstract &exc) {
267-
throw exc;
272+
throw;
268273
} catch (...) {
269274
DG_THROW ExceptionTraces(ExceptionTraces::NOT_OPEN,
270275
"The buffer is not open", "");

0 commit comments

Comments
 (0)