Xpetra Version of the Day
Loading...
Searching...
No Matches
Xpetra_EpetraExceptions.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Xpetra: A linear algebra interface package
4//
5// Copyright 2012 NTESS and the Xpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef XPETRA_EPETRAEXCEPTIONS_HPP
11#define XPETRA_EPETRAEXCEPTIONS_HPP
12
13#include "Xpetra_ConfigDefs.hpp"
14
15#ifndef HAVE_XPETRA_EPETRA
16#error This file should be included only if HAVE_XPETRA_EPETRA is defined.
17#endif
18
19#include "Xpetra_Exceptions.hpp"
20
21// This macro takes in argument a source code line.
22// It catchs exceptions that could be throwed by 'sourceCode'
23// If an exception is throw in any node, then all the node throws
24// an std::invalid_argument exceptions.
25#define IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG(sourceCode) \
26 { \
27 int localFailure = 0; /* 0 == success */ \
28 try { \
29 sourceCode; \
30 } catch (int /*epetraErrCode*/) { \
31 localFailure = 1; /* 1 == failure */ \
32 } \
33 \
34 { \
35 int globalFailure = 0; /* 0 == success */ \
36 Teuchos::reduceAll<int>(*comm, Teuchos::REDUCE_SUM, localFailure, Teuchos::outArg(globalFailure)); \
37 TEUCHOS_TEST_FOR_EXCEPTION(globalFailure != 0, std::invalid_argument, "Epetra threw exception"); \
38 } \
39 }
40#endif