46 #ifndef XPETRA_EXCEPTIONS_HPP 47 #define XPETRA_EXCEPTIONS_HPP 50 #include <Teuchos_Exceptions.hpp> 51 #include <Teuchos_Assert.hpp> 58 #define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg) \ 59 type * newObj ## _pt = dynamic_cast<type *>(&obj); \ 60 TEUCHOS_TEST_FOR_EXCEPTION(newObj ## _pt == NULL, Xpetra::Exceptions::BadCast, "Cannot cast '" #obj "' to a " #type ". " #exceptionMsg); \ 61 type & newObj = *newObj ## _pt; 65 #define XPETRA_RCP_DYNAMIC_CAST(type, obj, newObj, exceptionMsg) \ 66 const RCP<type > & newObj = Teuchos::rcp_dynamic_cast<type >(obj); \ 67 TEUCHOS_TEST_FOR_EXCEPTION(newObj == Teuchos::null, Xpetra::Exceptions::BadCast, "Cannot cast '" #obj "' to a " #type ". " #exceptionMsg); 69 #ifdef HAVE_XPETRA_EPETRA 70 #define XPETRA_FACTORY_ERROR_IF_EPETRA(lib) \ 71 if ((lib) == ::Xpetra::UseEpetra) \ 72 TEUCHOS_TEST_FOR_EXCEPTION(1, ::Xpetra::Exceptions::BadCast, "Epetra can only be used with Scalar=double and LocalOrdinal=GlobalOrdinal=int on a serial node"); 74 #define XPETRA_FACTORY_ERROR_IF_EPETRA(lib) 77 #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 #define XPETRA_TPETRA_ETI_EXCEPTION(cl,obj,go) TEUCHOS_TEST_FOR_EXCEPTION(1, ::Xpetra::Exceptions::BadCast, "Problem in " #cl "! Cannot create new object " #obj " with GO=" #go ". Xpetra has been compiled with Tpetra enabled but GO!=" #go ". Please add TPETRA_INST_INT_INT to your configuration."); 82 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).