Zoltan 2 Version 0.5
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_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.

Detailed Description

Defines exception handling macros.

Definition in file Zoltan2_Exceptions.hpp.


Define 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 64 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 80 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 95 of file Zoltan2_Exceptions.hpp.