CoolProp
Exceptions.h
1 
2 
3 #ifndef CPEXCEPTIONS_H
4 #define CPEXCEPTIONS_H
5 
6 #include <exception>
7 #include <iostream>
8 
9 namespace CoolProp {
10 
11 class CoolPropBaseError : public std::exception
12 {
13  public:
14  enum ErrCode
15  {
16  eNotImplemented,
17  eSolution,
18  eAttribute,
19  eOutOfRange,
20  eValue,
21  eWrongFluid,
22  eComposition,
23  eInput,
24  eNotAvailable,
25  eHandle,
26  eKey,
27  eUnableToLoad,
28  eDirectorySize
29  };
30  CoolPropBaseError(const std::string& err, ErrCode code) throw() : m_code(code), m_err(err) {}
31  ~CoolPropBaseError() throw(){};
32  virtual const char* what() const throw() {
33  return m_err.c_str();
34  }
35  ErrCode code() {
36  return m_code;
37  }
38 
39  private:
40  ErrCode m_code;
41  std::string m_err;
42 };
43 
44 template <CoolPropBaseError::ErrCode errcode>
46 {
47  public:
48  CoolPropError(const std::string& err = "", ErrCode ecode = errcode) throw() : CoolPropBaseError(err, ecode) {}
49 };
50 
60 
61 // ValueError specializations
62 template <CoolPropBaseError::ErrCode errcode>
63 class ValueErrorSpec : public ValueError
64 {
65  public:
66  ValueErrorSpec(const std::string& err = "", ErrCode ecode = errcode) throw() : ValueError(err, ecode) {}
67 };
68 
73 
74 }; /* namespace CoolProp */
75 #endif
Definition: Exceptions.h:11
Definition: Exceptions.h:45
Definition: Exceptions.h:63
This file contains flash routines in which the state is unknown, and a solver of some kind must be us...
Definition: AbstractState.h:19