|
Sierra Toolkit
Version of the Day
|
Go to the documentation of this file.
9 #ifndef STK_UTIL_PARALLEL_Exception_hpp
10 #define STK_UTIL_PARALLEL_Exception_hpp
72 #include <stk_util/stk_config.h>
73 #if defined( STK_HAS_MPI )
77 #include <stk_util/environment/ReportHandler.hpp>
79 #include <stk_util/util/FeatureTest.hpp>
81 #include <stk_util/diag/StringUtil.hpp>
82 #include <stk_util/diag/Trace.hpp>
151 void throw_copy(
const std::exception &x,
const std::string &message);
216 register_exception_a(
typeid(T), x);
217 register_exception_a(
typeid(
typename T::BaseExceptionType), x);
244 ExParallel ®ister_exception_a(
const std::type_info ¶llel_exception_type,
ExParallel *exception);
252 class Registry :
public std::vector<std::pair<const std::type_info *, ExParallel *> >
280 : m_descriptionStream(),
282 m_traceback(Diag::Trace::printTraceback(Diag::Trace::Traceback::snapshot())),
299 explicit ExParallel(
const std::string & message,
int parallel = -1)
300 : m_descriptionStream(),
302 m_traceback(Diag::Trace::printTraceback(Diag::Trace::Traceback::snapshot())),
305 m_descriptionStream << message;
317 : m_descriptionStream(),
319 m_traceback(x.m_traceback),
320 m_parallel(x.m_parallel)
322 m_descriptionStream << x.m_descriptionStream.str();
339 virtual const char *
what()
const throw() {
341 m_whatBuffer = m_descriptionStream.str();
342 return m_whatBuffer.c_str();
355 m_descriptionStream.str(
"");
372 m_descriptionStream << description;
384 return m_descriptionStream.str();
395 return m_descriptionStream;
406 return m_descriptionStream;
419 m_traceback = traceback;
444 m_parallel = parallel;
468 return m_parallel != -1;
480 f(m_descriptionStream);
495 m_descriptionStream << t;
521 std::ostringstream m_descriptionStream;
522 mutable std::string m_whatBuffer;
523 std::string m_traceback;
557 explicit ExTemp(
const std::string &message)
569 T(static_cast<const T &>(x))
585 virtual const char *
what()
const throw() {
639 #ifdef SIERRA_TEMPLATE_CALL_BUG
649 class ExTemp1 :
public ExParallel,
public T
652 typedef ExTemp1<T> ParallelExceptionType;
653 typedef T BaseExceptionType;
670 explicit ExTemp1(
const std::string & message)
680 ExTemp1(
const ExTemp1 & x)
682 T(static_cast<const T &>(x))
689 virtual ~ExTemp1() throw()
698 virtual const char *what()
const throw() {
710 ExTemp1 &
operator<<(std::ostream& (*f)(std::ostream&)) {
741 ParallelExceptionType t(*
this);
756 #ifdef SIERRA_TEMPLATE_CALL_BUG
790 : std::runtime_error(message)
794 : std::runtime_error(x)
801 typedef ExTemp1<runtime_user_error> RuntimeUserError;
813 #define StackTraceMessage " exception thrown from "
814 #define ParallelStackTraceMessage " parallel exception thrown from "
815 #define ParallelStackTrace std::string(std::string(ParallelStackTraceMessage) + stk_classic::source_relative_path(STR_TRACE))
817 #endif // STK_UTIL_PARALLEL_Exception_hpp
ExTemp1< std::underflow_error > UnderflowError
Defined in <stdexcept>
Template ExTemp takes a zero argument exception and makes it into a parallel throwable and put-to-abl...
ExParallel & setParallel(int parallel)
Member function setParallel sets the originating processor for an exception that is being thrown in p...
void throw_copy(const std::exception &x, const std::string &append_message)
Function throw_copy throws a copy of the exception. The exception is located in the parallel exceptio...
Class ParallelThrowRegistry is a registry of known parallel exceptions. For the negotiation of parall...
virtual const char * what() const
Member function what returns the exception's description.
ExTemp & operator<<(std::ostream &(*f)(std::ostream &))
Member function operator<< passes the std manipilator functions to the ExTemp object....
virtual void parallel_handler()
Member function parallel_handler is called just before a parallel exception is thrown....
virtual const char * what() const
Member function what returns the exception's description.
const std::string & getTraceback() const
Member function getTraceback returns the exception's traceback string.
T BaseExceptionType
Base exception type.
void set_exception()
Function set_exception is called on a single processor when an exception is caught....
void register_stl_parallel_exceptions()
Member function register_stl_parallel_exceptions registers the stl exceptions with the parallel excep...
ExParallel * findException(const std::type_info &exception_type)
Member function findException returns a pointer to the matching exception in parallel exception regis...
ExTemp1< std::logic_error > LogicError
Defined in <stdexcept>
std::ostream & operator<<(std::ostream &s, const Bucket &k)
Print the part names for which this bucket is a subset.
Class ExParallel implements the features of a parallel exception. It is a std::string which stores th...
ExTemp< T > ParallelExceptionType
Parallel exception type.
ExTemp1< std::overflow_error > OverflowError
Defined in <stdexcept>
ExTemp1< std::runtime_error > RuntimeError
Defined in <stdexcept>
ExParallel & operator<<(const U &t)
ExParallel & operator<<(std::ostream &(*f)(std::ostream &))
Member function operator<< passes the std manipilator functions to the ExParallel object....
ExParallel & registerException()
Member template function registerException registers an exception of the specified type with the para...
ExParallel & clear()
Member function clear clears the contents of the exception.
ExTemp< std::bad_typeid > BadTypeid
Defined in <typeinfo>
ExTemp & operator<<(const U &t)
ExParallel & setDescription(const std::string &description)
Member function setDescription sets the value of the exception's description.
ExTemp1< std::out_of_range > OutOfRange
Defined in <stdexcept>
ExTemp1< std::domain_error > DomainError
Defined in <stdexcept>
ExTemp1< std::ios_base::failure > IosBaseFailure
Defined in <ios>
ExTemp1< std::range_error > RangeError
Defined in <stdexcept>
virtual void throw_copy() const =0
Member function throw_copy is a pure virtual function which is allows the copying and throwing of the...
ExParallel & setTraceback(const std::string &traceback)
Member function setTraceback sets the exception's traceback to the caller generating the exception.
ExParallel(const std::string &message, int parallel=-1)
std::ostringstream & getDescriptionStream()
Member function getDescriptionStream returns the stream used to assemble the description.
static bool areExceptionsRegistered()
Static member function setExceptionsRegistered sets the exceptions have been registered flag....
int getParallel() const
Member function getParallel returns the originating processor for a parallel exception or -1 if the e...
void parallel_throw(MPI_Comm mpi_comm)
Function parallel_throw throws a consistant exception in parallel. parallel_throw is called after the...
std::string getDescription() const
Member function getDescription returns the exception's description.
static ParallelThrowRegistry & instance()
Member function instance returns the singleton instance for the parallel exception registry.
ExTemp1< std::invalid_argument > InvalidArgument
Defined in <stdexcept>
void sierra_exception_throw()
Member function sierra_exception_throw is called whenever a parallel exception is constructed....
ExTemp< std::exception > Exception
Defined in
static void registerException()
Member function registerException registers the exception with the parallel exception registry.
ExTemp(const std::string &message)
ExTemp< std::bad_alloc > BadAlloc
Defined in <new>
ExTemp< std::bad_cast > BadCast
Defined in <typeinfo>
const std::ostringstream & getDescriptionStream() const
Member function getDescriptionStream returns the stream used to assemble the description.
ExParallel(const ExParallel &x)
virtual void throw_copy() const
Member function copy throws a copy of the original exception. It copies the original message,...
ExTemp< std::bad_exception > BadException
Defined in
Class runtime_user_error ...
ExTemp1< std::length_error > LengthError
Defined in <stdexcept>
bool isParallel() const
Member function isParallel returns true if the exception is being thrown in parallel.