46 #ifndef XPETRA_EXCEPTIONS_HPP 
   47 #define XPETRA_EXCEPTIONS_HPP 
   50 #include <Teuchos_Exceptions.hpp> 
   51 #include <Teuchos_Assert.hpp> 
   57 #define XPETRA_COMMA , 
   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,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."); 
   82   namespace Exceptions {
 
   86     class BadCast : 
public Teuchos::ExceptionBase
 
   89       BadCast(
const std::string& what_arg) : Teuchos::ExceptionBase(what_arg) {}
 
   97       NotImplemented(
const std::string& what_arg) : Teuchos::ExceptionBase(what_arg) {}
 
  104       RuntimeError(
const std::string& what_arg) : Teuchos::ExceptionBase(what_arg) {}
 
  110       Incompatible(
const std::string& what_arg) : 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).