libcryptosec
EngineException.h
Go to the documentation of this file.
1 #ifndef ENGINEEXCEPTION_H_
2 #define ENGINEEXCEPTION_H_
3 
5 
7 {
8 public:
9  enum ErrorCode
10  {
22  };
23  EngineException(std::string where)
24  {
25  this->where = where;
27  this->details = "";
28  }
30  {
31  this->where = where;
32  this->errorCode = errorCode;
33  this->details = "";
34  }
36  {
37  this->where = where;
38  this->errorCode = errorCode;
39  this->details = details;
40  }
41  EngineException(EngineException::ErrorCode errorCode, std::string where, bool opensslDetails)
42  {
43  this->where = where;
44  this->errorCode = errorCode;
45  if (opensslDetails)
46  {
48  }
49  else
50  {
51  this->details = "";
52  }
53  }
54  virtual ~EngineException() throw () {}
55  virtual std::string getMessage() const
56  {
57 // return (EngineException::errorCode2Message(this->errorCode) + ". Details: " +details);
59  }
60  virtual std::string toString() const
61  {
62  std::string ret;
64  {
65  ret = "EngineException. Called by: " + this->where + ".";
66  }
67  else
68  {
69  ret = "EngineException: " + EngineException::errorCode2Message(this->errorCode) + ". Called by: " + this->where + ".";
70  }
71  if (this->details != "")
72  {
73  ret += " More details:\n" + this->details + ".";
74  }
75  return ret;
76  }
78  {
79  return this->errorCode;
80  }
82  {
83  std::string ret;
84  switch (errorCode)
85  {
87  ret = "Unknown error";
88  break;
90  ret = "Engine initialization failed";
91  break;
93  ret = "Key id not found";
94  break;
96  ret = "Adding engine to engines list";
97  break;
99  ret = "Removing engine from engines list";
100  break;
102  ret = "Dynamic engine is not available";
103  break;
105  ret = "Internal error";
106  break;
108  ret = "Engine not found";
109  break;
111  ret = "Setting command";
112  break;
114  ret = "Invalid engine";
115  break;
117  ret = "Load engine failed";
118  break;
119 // case EngineException:::
120 // ret = "";
121 // break;
122 // case EngineException:::
123 // ret = "";
124 // break;
125  }
126  return ret;
127  }
128 protected:
130 };
131 
132 #endif /*ENGINEEXCEPTION_H_*/
Definition: EngineException.h:19
Definition: EngineException.h:15
virtual EngineException::ErrorCode getErrorCode()
Definition: EngineException.h:77
virtual std::string toString() const
Definition: EngineException.h:60
Definition: EngineException.h:13
EngineException::ErrorCode errorCode
Definition: EngineException.h:129
EngineException(EngineException::ErrorCode errorCode, std::string where, bool opensslDetails)
Definition: EngineException.h:41
Definition: EngineException.h:16
Definition: EngineException.h:21
Definition: EngineException.h:12
Definition: EngineException.h:14
EngineException(EngineException::ErrorCode errorCode, std::string where)
Definition: EngineException.h:29
Definition: EngineException.h:6
virtual ~EngineException()
Definition: EngineException.h:54
virtual std::string getMessage() const
Definition: EngineException.h:55
ErrorCode
Definition: EngineException.h:9
EngineException(std::string where)
Definition: EngineException.h:23
Definition: LibCryptoSecException.h:8
std::string where
Definition: LibCryptoSecException.h:23
Definition: EngineException.h:11
std::string details
Definition: LibCryptoSecException.h:24
Definition: EngineException.h:17
Definition: EngineException.h:18
Definition: EngineException.h:20
EngineException(EngineException::ErrorCode errorCode, std::string where, std::string details)
Definition: EngineException.h:35
static std::string getErrors()
Definition: OpenSSLErrorHandler.cpp:56
static std::string errorCode2Message(EngineException::ErrorCode errorCode)
Definition: EngineException.h:81