File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -88,11 +88,12 @@ Tracer::Tracer(const std::string n)
88
88
void Tracer::addSignalToTrace (const SignalBase<int > &sig,
89
89
const string &filename) {
90
90
dgDEBUGIN (15 );
91
+ // openFile may throw so it should be called first.
92
+ if (namesSet)
93
+ openFile (sig, filename);
91
94
toTraceSignals.push_back (&sig);
92
95
dgDEBUGF (15 , " %p" , &sig);
93
96
names.push_back (filename);
94
- if (namesSet)
95
- openFile (sig, filename);
96
97
triger.addDependency (sig);
97
98
dgDEBUGOUT (15 );
98
99
}
Original file line number Diff line number Diff line change @@ -65,11 +65,16 @@ BOOST_AUTO_TEST_CASE(test_tracer) {
65
65
std::string basename (" my-tracer" );
66
66
std::string suffix (" .dat" );
67
67
68
- // / Test openfiles
69
68
atracer.setBufferSize (1 <<14 );
70
- atracer.openFiles (rootdir, basename, suffix);
71
69
72
- // / Add trace by name
70
+ // Check that an exception is thrown if the filename is invalid.
71
+ atracer.openFiles (rootdir, " invalid/filename" , suffix);
72
+ BOOST_CHECK_THROW (atracer.addSignalToTraceByName (" my-entity.out_double" , " output" ),
73
+ ExceptionTraces);
74
+
75
+ // Test openfiles
76
+ atracer.openFiles (rootdir, basename, suffix);
77
+ // Add trace by name
73
78
atracer.addSignalToTraceByName (" my-entity.out_double" , " output" );
74
79
75
80
// / Add trace by name
You can’t perform that action at this time.
0 commit comments