Zoltan2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Namespaces | Macros
Zoltan2_Exceptions.hpp File Reference

Defines exception handling macros. More...

#include <stdexcept>
#include <iostream>
#include <sstream>
#include <string>
Include dependency graph for Zoltan2_Exceptions.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Zoltan2::NotImplemented
 Exception thrown when a called base-class method is not implemented. More...
 

Namespaces

 Zoltan2
 Created by mbenlioglu on Aug 31, 2020.
 

Macros

#define Z2_THROW_OUTSIDE_ERROR(env)
 Throw an error returned from outside the Zoltan2 library. More...
 
#define Z2_THROW_NOT_IMPLEMENTED   { throw Zoltan2::NotImplemented(__FILE__, __LINE__, __func__zoltan2__); }
 
#define Z2_FORWARD_EXCEPTIONS
 Forward an exception back through call stack. More...
 
#define Z2_THROW_EXPERIMENTAL(mystr)
 Throw an error when experimental code is requested but not compiled. More...
 
#define Z2_THROW_EXPERIMENTAL_WOLF(mystr)
 Throw an error when wolf experimental code is requested but not compiled. More...
 
#define Z2_THROW_SERIAL(mystr)
 Throw an error when code is run on more than one processor. More...
 
#define Z2_ASSERT_VALUE(actual, expected)
 Throw an error when actual value is not equal to expected value. More...
 
#define __func__zoltan2__   __func__
 

Detailed Description

Defines exception handling macros.

Definition in file Zoltan2_Exceptions.hpp.

Macro Definition Documentation

#define Z2_THROW_OUTSIDE_ERROR (   env)
Value:
catch (std::exception &e) { \
std::cerr<<(env).myRank_<<" "<<__FILE__<<","<<__LINE__<<","<<e.what()<<std::endl; \
throw e; \
}

Throw an error returned from outside the Zoltan2 library.

A try block that calls another library should be followed by this catch block. The error message if any is printed and the exception is then thrown.

Definition at line 28 of file Zoltan2_Exceptions.hpp.

#define Z2_THROW_NOT_IMPLEMENTED   { throw Zoltan2::NotImplemented(__FILE__, __LINE__, __func__zoltan2__); }

Definition at line 56 of file Zoltan2_Exceptions.hpp.

#define Z2_FORWARD_EXCEPTIONS
Value:
catch (std::runtime_error &e) { throw e; } \
catch (std::logic_error &e) { throw e; } \
catch (std::bad_alloc &e) { throw e; } \
catch (std::exception &e) { throw e; }

Forward an exception back through call stack.

A try block that calls another Zoltan2 function should be followed by this catch series. It ensures that the original runtime, logic or bad_alloc exception gets passed up. For example, if a runtime_error is caught as a std::exception, it gets passed up as a std::exception and the what() message is not lost.

Definition at line 70 of file Zoltan2_Exceptions.hpp.

#define Z2_THROW_EXPERIMENTAL (   mystr)
Value:
{ \
std::ostringstream oss; \
oss << (mystr) << std::endl \
<< "To experiment with this software, configure with " \
<< "-D Zoltan2_ENABLE_Experimental:BOOL=ON " \
<< std::endl; \
throw std::runtime_error(oss.str()); \
}

Throw an error when experimental code is requested but not compiled.

Experimental code must be enabled with CMAKE Option -D Zoltan2_ENABLE_Experimental:BOOL=ON If it is not enabled but it is called, throw an exception. The input string mystr is a use-specific message included in the throw message.

Definition at line 85 of file Zoltan2_Exceptions.hpp.

#define Z2_THROW_EXPERIMENTAL_WOLF (   mystr)
Value:
{ \
std::ostringstream oss; \
oss << (mystr) << std::endl \
<< "To experiment with this software, configure with " \
<< "-D Zoltan2_ENABLE_Experimental_Wolf:BOOL=ON " \
<< std::endl; \
throw std::runtime_error(oss.str()); \
}

Throw an error when wolf experimental code is requested but not compiled.

Experimental code must be enabled with CMAKE Option -D Zoltan2_ENABLE_Experimental_Wolf:BOOL=ON If it is not enabled but it is called, throw an exception. The input string mystr is a use-specific message included in the throw message.

Definition at line 104 of file Zoltan2_Exceptions.hpp.

#define Z2_THROW_SERIAL (   mystr)
Value:
{ \
std::ostringstream oss; \
oss << (mystr) << std::endl \
<< "This algorithm only runs in serial (Comm_Serial or MPI_Comm with worldsize=1). " \
<< std::endl; \
throw std::runtime_error(oss.str()); \
}

Throw an error when code is run on more than one processor.

Definition at line 118 of file Zoltan2_Exceptions.hpp.

#define Z2_ASSERT_VALUE (   actual,
  expected 
)
Value:
{ \
if (actual != expected) \
{ \
std::ostringstream oss; \
oss << "Expected value " << expected << "does not match actual value"\
<< actual << "in" << __FILE__<<", "<<__LINE__ \
<< std::endl; \
throw std::runtime_error(oss.str()); \
}\
}

Throw an error when actual value is not equal to expected value.

Check if the two arguments passed are equal and throw a runtime error if they are not.

Definition at line 134 of file Zoltan2_Exceptions.hpp.

#define __func__zoltan2__   __func__

Definition at line 153 of file Zoltan2_Exceptions.hpp.