QMCPACK
MPIExceptionWrapper.hpp
Go to the documentation of this file.
1
//////////////////////////////////////////////////////////////////////////////////////
2
// This file is distributed under the University of Illinois/NCSA Open Source License.
3
// See LICENSE file in top directory for details.
4
//
5
// Copyright (c) 2020 QMCPACK developers.
6
//
7
// File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
8
//
9
// File created by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
10
//////////////////////////////////////////////////////////////////////////////////////
11
12
#ifndef MPIEXECPTIONWRAPPER_H
13
#define MPIEXECPTIONWRAPPER_H
14
15
#include "
Message/Communicate.h
"
16
17
namespace
qmcplusplus
18
{
19
20
class
MPIExceptionWrapper
21
{
22
public
:
23
MPIExceptionWrapper
() {};
24
25
/** Call an arbitrary function that can throw an exception catch it, extract message,
26
* and call APP_ABORT
27
*
28
*/
29
template
<
typename
F,
typename
... Args>
30
void
operator()
(F&& f, Args&&... args);
31
32
};
33
34
template
<
typename
F,
typename
... Args>
35
void
MPIExceptionWrapper::operator()
(F&& f, Args&&... args)
36
{
37
try
38
{
39
f(std::forward<Args>(args)...);
40
}
41
catch
(
const
std::exception& re)
42
{
43
APP_ABORT
(re.what());
44
}
45
catch
(...)
46
{
47
APP_ABORT
(
"MPIExceptionWrapper caught an unknown exception!"
);
48
}
49
50
}
51
52
}
53
54
55
#endif
/* MPIEXECPTIONWRAPPER_H */
qmcplusplus
helper functions for EinsplineSetBuilder
Definition:
Configuration.h:43
qmcplusplus::MPIExceptionWrapper::MPIExceptionWrapper
MPIExceptionWrapper()
Definition:
MPIExceptionWrapper.hpp:23
APP_ABORT
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition:
AppAbort.h:27
qmcplusplus::MPIExceptionWrapper::operator()
void operator()(F &&f, Args &&... args)
Call an arbitrary function that can throw an exception catch it, extract message, and call APP_ABORT...
Definition:
MPIExceptionWrapper.hpp:35
qmcplusplus::MPIExceptionWrapper
Definition:
MPIExceptionWrapper.hpp:20
Communicate.h
src
Utilities
MPIExceptionWrapper.hpp
Generated on Fri Jun 28 2024 10:45:29 for QMCPACK by
1.8.14