Skip to content
Snippets Groups Projects
Commit ce88883e authored by Maik Nijhuis's avatar Maik Nijhuis
Browse files

Merge branch 'catch-h5-exceptions' into 'master'

Catch HDF5 exceptions in DP3 main

See merge request !1033
parents 995f113e 07ab90b5
No related branches found
No related tags found
1 merge request!1033Catch HDF5 exceptions in DP3 main
Pipeline #51170 passed
...@@ -130,13 +130,11 @@ if(ENABLE_EXPERIMENTAL_SCREENFITTER) ...@@ -130,13 +130,11 @@ if(ENABLE_EXPERIMENTAL_SCREENFITTER)
endif() endif()
endif() endif()
# Casacore depends on HDF5 -> First load HDF5. # Load HDF5 before Casacore, since some Casacore versions do not load HDF5.
find_package( find_package(
HDF5 HDF5
COMPONENTS C CXX COMPONENTS C CXX
REQUIRED) REQUIRED)
add_definitions(${HDF5_DEFINITIONS})
include_directories(${HDF5_INCLUDE_DIRS})
find_package( find_package(
Casacore Casacore
...@@ -144,6 +142,15 @@ find_package( ...@@ -144,6 +142,15 @@ find_package(
REQUIRED) REQUIRED)
include_directories(SYSTEM ${CASACORE_INCLUDE_DIR}) include_directories(SYSTEM ${CASACORE_INCLUDE_DIR})
# Reload HDF5, since some Casacore versions also load HDF5, but without C++
# support. ${HDF5_LIBRARIES} then does not include C++ libraries.
find_package(
HDF5
COMPONENTS C CXX
REQUIRED)
add_definitions(${HDF5_DEFINITIONS})
include_directories(${HDF5_INCLUDE_DIRS})
find_package(CFITSIO REQUIRED) find_package(CFITSIO REQUIRED)
include_directories(${CFITSIO_INCLUDE_DIRS}) include_directories(${CFITSIO_INCLUDE_DIRS})
...@@ -562,7 +569,7 @@ set(SOURCEDB_LIBRARIES Blob Common ParmDB ${CASACORE_LIBRARIES} ...@@ -562,7 +569,7 @@ set(SOURCEDB_LIBRARIES Blob Common ParmDB ${CASACORE_LIBRARIES}
${Boost_SYSTEM_LIBRARY}) ${Boost_SYSTEM_LIBRARY})
add_executable(DP3 base/Main.cc) add_executable(DP3 base/Main.cc)
target_link_libraries(DP3 LIBDP3) target_link_libraries(DP3 LIBDP3 ${HDF5_LIBRARIES})
add_executable(makesourcedb parmdb/makesourcedb.cc) add_executable(makesourcedb parmdb/makesourcedb.cc)
target_link_libraries(makesourcedb ${SOURCEDB_LIBRARIES}) target_link_libraries(makesourcedb ${SOURCEDB_LIBRARIES})
......
...@@ -4,15 +4,17 @@ ...@@ -4,15 +4,17 @@
// //
// @author Ger van Diepen // @author Ger van Diepen
#include <dp3/base/DP3.h> #include <filesystem>
#include <iostream>
#include <stdexcept>
#include <Version.h> #include <H5Cpp.h>
#include <aocommon/checkblas.h> #include <aocommon/checkblas.h>
#include <filesystem> #include <dp3/base/DP3.h>
#include <iostream>
#include <stdexcept> #include <Version.h>
// Define handler that tries to print a backtrace. // Define handler that tries to print a backtrace.
// Exception::TerminateHandler t(Exception::terminate); // Exception::TerminateHandler t(Exception::terminate);
...@@ -70,9 +72,17 @@ int main(int argc, char* argv[]) { ...@@ -70,9 +72,17 @@ int main(int argc, char* argv[]) {
// Execute the parset file. // Execute the parset file.
dp3::base::Execute(parsetName, argc, argv); dp3::base::Execute(parsetName, argc, argv);
} catch (std::exception& err) { } catch (const std::exception& err) {
std::cerr << "\nstd exception detected: " << err.what() << '\n'; std::cerr << "\nstd exception detected: " << err.what() << '\n';
return 1; return 1;
} catch (const H5::Exception& err) {
// Since H5::Exception is not derived from std::exception, DP3 crashes
// if it does not catch them -> Print an error message instead.
std::cerr << "\nH5 exception detected: " << err.getDetailMsg()
<< "\nStack trace:\n";
err.printErrorStack();
std::cerr << '\n';
return 1;
} }
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment