Simpatico  v1.10
Exception.h
1 #ifndef UTIL_EXCEPTION_H
2 #define UTIL_EXCEPTION_H
3 
4 /*
5 * Util Package - C++ Utilities for Scientific Computation
6 *
7 * Copyright 2010 - 2017, The Regents of the University of Minnesota
8 * Distributed under the terms of the GNU General Public License.
9 */
10 
11 #include <iostream>
12 #include <string>
13 
14 namespace Util
15 {
16 
24  class Exception
25  {
26 
27  public:
28 
47  Exception(const char *function, const char *message,
48  const char *file, int line, int echo = 1);
49 
58  Exception(const char *message, const char *file, int line, int echo = 1);
59 
63  virtual ~Exception();
64 
70  void write(std::ostream &out);
71 
75  std::string& message();
76 
77  protected:
78 
80  std::string message_;
81 
82  };
83 
84  #ifdef UTIL_MPI
85 
94  void MpiThrow(Exception& e);
95  #endif
96 
97 }
98 #endif
std::string & message()
Return the error message.
Definition: Exception.cpp:83
Utility classes for scientific computation.
Definition: accumulators.mod:1
void MpiThrow(Exception &e)
Function to throw exception in MPI code.
Definition: Exception.cpp:90
Exception(const char *function, const char *message, const char *file, int line, int echo=1)
Constructor.
Definition: Exception.cpp:22
virtual ~Exception()
Destructor.
Definition: Exception.cpp:71
void write(std::ostream &out)
Write error message to output stream.
Definition: Exception.cpp:77
std::string message_
Error message string.
Definition: Exception.h:80
A user-defined exception.
Definition: Exception.h:24