Cantera  2.0
vcs_Exception.h
Go to the documentation of this file.
1 /**
2  * @file vcs_Exception.h
3  */
4 /*
5  * Copyright (2005) Sandia Corporation. Under the terms of
6  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
7  * U.S. Government retains certain rights in this software.
8  */
9 #ifndef VCS_EXCEPTION_H
10 #define VCS_EXCEPTION_H
11 
12 #include <string>
13 
14 namespace VCSnonideal
15 {
16 
17 class vcsError
18 {
19 public:
20  vcsError(std::string proc, std::string msg, int errorCode=-1);
21  virtual ~vcsError() {}
22 protected:
23  std::string m_proc;
24  std::string m_msg;
25  int m_errorCode;
26 };
27 
28 
29 //! Assertion must be true or an error is thrown
30 /*!
31  * Assertion must be true or else a vcsError is thrown. A diagnostic
32  * string indicating where the error
33  * occured is added to the thrown object.
34  *
35  * @param expr Boolean expression that must be true
36  * @param proc Character string or std:string expression indicating the procedure
37  * where the assertion failed
38  * @ingroup errorhandling
39  */
40 #define AssertThrowVCS(expr, proc) ((expr) ? (void) 0 : throw vcsError(proc, std::string("failed Assert: ") + #expr,-1))
41 
42 #ifdef DEBUG_HKM
43 #define DebugAssertThrowVCS(expr, proc) ((expr) ? (void) 0 : throw vcsError(proc, std::string("failed debugAssert: ") + #expr,-1))
44 #else
45 #define DebugAssertThrowVCS(expr, proc)
46 #endif
47 
48 }
49 
50 #endif