10 #ifndef XPETRA_EXCEPTIONS_HPP
11 #define XPETRA_EXCEPTIONS_HPP
14 #include <Teuchos_Exceptions.hpp>
15 #include <Teuchos_Assert.hpp>
21 #define XPETRA_COMMA ,
22 #define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg) \
23 type* newObj##_pt = dynamic_cast<type*>(&obj); \
24 TEUCHOS_TEST_FOR_EXCEPTION(newObj##_pt == NULL, Xpetra::Exceptions::BadCast, "Cannot cast '" #obj "' to a " #type ". " #exceptionMsg); \
25 type& newObj = *newObj##_pt;
29 #define XPETRA_RCP_DYNAMIC_CAST(type, obj, newObj, exceptionMsg) \
30 const RCP<type>& newObj = Teuchos::rcp_dynamic_cast<type>(obj); \
31 TEUCHOS_TEST_FOR_EXCEPTION(newObj == Teuchos::null, Xpetra::Exceptions::BadCast, "Cannot cast '" #obj "' to a " #type ". " #exceptionMsg);
33 #ifdef HAVE_XPETRA_EPETRA
34 #define XPETRA_FACTORY_ERROR_IF_EPETRA(lib) \
35 if ((lib) == ::Xpetra::UseEpetra) \
36 TEUCHOS_TEST_FOR_EXCEPTION(1, ::Xpetra::Exceptions::BadCast, "Epetra can only be used with Scalar=double and LocalOrdinal=GlobalOrdinal=int on a serial node");
38 #define XPETRA_FACTORY_ERROR_IF_EPETRA(lib)
41 #define XPETRA_FACTORY_END TEUCHOS_TEST_FOR_EXCEPTION(1, ::Xpetra::Exceptions::BadCast, "Unknown map->lib() type. Did you compile with Epetra and Tpetra support?");
43 #define XPETRA_TPETRA_ETI_EXCEPTION(cl, obj, go, node) TEUCHOS_TEST_FOR_EXCEPTION(1, ::Xpetra::Exceptions::BadCast, "Problem in " #cl "! Cannot create new object " #obj " with GO=" #go " and NO=" #node ". Xpetra has been compiled with Tpetra enabled but GO=" #go " disabled and/or NO=" #node " disabled. Please check your Trilinos configuration.");
46 namespace Exceptions {
50 class BadCast :
public Teuchos::ExceptionBase {
53 : Teuchos::ExceptionBase(what_arg) {}
61 : Teuchos::ExceptionBase(what_arg) {}
68 : Teuchos::ExceptionBase(what_arg) {}
75 : Teuchos::ExceptionBase(what_arg) {}
Incompatible(const std::string &what_arg)
Exception throws to report errors in the internal logical of the program.
NotImplemented(const std::string &what_arg)
Exception indicating invalid cast attempted.
RuntimeError(const std::string &what_arg)
BadCast(const std::string &what_arg)
Exception throws when you call an unimplemented method of Xpetra.
Exception throws to report incompatible objects (like maps).