Zoltan2
Defines
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.

Defines

#define Z2_THROW_NOT_IMPLEMENTED_ERROR
 Throw an error for input adapter functions that have been called by the model but not implemented in the adapter.
#define Z2_THROW_OUTSIDE_ERROR(env)
 Throw an error returned from outside the Zoltan2 library.
#define Z2_FORWARD_EXCEPTIONS
 Forward an exception back through call stack.
#define Z2_THROW_EXPERIMENTAL(mystr)
 Throw an error when experimental code is requested but not compiled.
#define Z2_THROW_EXPERIMENTAL_WOLF(mystr)
 Throw an error when wolf experimental code is requested but not compiled.
#define Z2_ASSERT_VALUE(actual, expected)
 Throw an error when actual value is not equal to expected value.

Detailed Description

Defines exception handling macros.

Definition in file Zoltan2_Exceptions.hpp.


Define Documentation

#define Z2_THROW_NOT_IMPLEMENTED_ERROR
Value:
{ \
    std::ostringstream emsg; \
    emsg << __FILE__ << "," << __LINE__ \
         << " error:  " << __func__ << " not implemented in adapter "  \
         << std::endl; \
    throw std::runtime_error(emsg.str()); \
  }

Throw an error for input adapter functions that have been called by the model but not implemented in the adapter.

Definition at line 62 of file Zoltan2_Exceptions.hpp.

#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 78 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 lost.

Definition at line 94 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 109 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 128 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 144 of file Zoltan2_Exceptions.hpp.