mirror of
https://github.com/Unidata/netcdf-cxx4.git
synced 2024-11-21 03:13:46 +08:00
assuring no exception is thrown from ncFile dtor
This commit is contained in:
parent
76a61b9ba7
commit
0d1698d09b
@ -12,7 +12,17 @@ using namespace netCDF::exceptions;
|
||||
// destructor
|
||||
NcFile::~NcFile()
|
||||
{
|
||||
ncCheck(nc_close(myId),__FILE__,__LINE__);
|
||||
// destructor may be called due to an exception being thrown
|
||||
// hence throwing an exception from within a destructor
|
||||
// causes undefined behaviour! so just printing a warning message
|
||||
try
|
||||
{
|
||||
ncCheck(nc_close(myId),__FILE__,__LINE__);
|
||||
}
|
||||
catch (NcException &e)
|
||||
{
|
||||
cerr << e.what() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Constructor generates a null object.
|
||||
|
Loading…
Reference in New Issue
Block a user