46 #ifndef XPETRA_EXCEPTIONS_HPP 47 #define XPETRA_EXCEPTIONS_HPP 50 #include <Teuchos_Exceptions.hpp> 51 #include <Teuchos_Assert.hpp> 57 #define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg) \ 58 type * newObj ## _pt = dynamic_cast<type *>(&obj); \ 59 TEUCHOS_TEST_FOR_EXCEPTION(newObj ## _pt == NULL, Xpetra::Exceptions::BadCast, "Cannot cast '" #obj "' to a " #type ". " #exceptionMsg); \ 60 type & newObj = *newObj ## _pt; 64 #define XPETRA_RCP_DYNAMIC_CAST(type, obj, newObj, exceptionMsg) \ 65 const RCP<type > & newObj = Teuchos::rcp_dynamic_cast<type >(obj); \ 66 TEUCHOS_TEST_FOR_EXCEPTION(newObj == Teuchos::null, Xpetra::Exceptions::BadCast, "Cannot cast '" #obj "' to a " #type ". " #exceptionMsg); 68 #ifdef HAVE_XPETRA_EPETRA 69 #define XPETRA_FACTORY_ERROR_IF_EPETRA(lib) \ 70 if ((lib) == ::Xpetra::UseEpetra) \ 71 TEUCHOS_TEST_FOR_EXCEPTION(1, ::Xpetra::Exceptions::BadCast, "Epetra can only be used with Scalar=double and Ordinal=int"); 73 #define XPETRA_FACTORY_ERROR_IF_EPETRA(lib) 76 #define XPETRA_FACTORY_END TEUCHOS_TEST_FOR_EXCEPTION(1, ::Xpetra::Exceptions::BadCast, "Unknown map->lib() type. Did you compile with Epetra and Tpetra support?"); 79 namespace Exceptions {
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).