libcryptosec
EncodeException.h
Go to the documentation of this file.
1 #ifndef ENCODEEXCEPTION_H_
2 #define ENCODEEXCEPTION_H_
3 
4 #include <openssl/err.h>
5 
7 
9 {
10 public:
11  enum ErrorCode
12  {
13  UNKNOWN = 0,
23  };
24  EncodeException(std::string where)
25  {
26  this->where = where;
28  }
30  {
31  this->where = where;
32  this->errorCode = errorCode;
33  }
34  virtual ~EncodeException() throw () {}
35  virtual std::string getMessage() const
36  {
38  }
39  virtual std::string toString() const
40  {
41  std::string ret;
43  {
44  ret = "EncodeException. Called by: " + this->where + ".";
45  }
46  else
47  {
48  ret = "EncodeException: " + EncodeException::errorCode2Message(this->errorCode) + ". Called by: " + this->where + ".";
49  }
50  return ret;
51  }
53  {
54  return this->errorCode;
55  }
57  {
58  std::string ret;
59  switch (errorCode)
60  {
62  ret = "Unknown error";
63  break;
65  ret = "Creating a buffer";
66  break;
68  ret = "Reading data from a buffer";
69  break;
71  ret = "Writing data to a buffer";
72  break;
74  ret = "Encoding DER format";
75  break;
77  ret = "Decoding DER format";
78  break;
80  ret = "Encoding PEM format";
81  break;
83  ret = "Decoding PEM format";
84  break;
86  ret = "Base64 encode";
87  break;
89  ret = "Base64 decode";
90  break;
91 // case EncodeException:::
92 // ret = "";
93 // break;
94  }
95  return ret;
96  }
97 
98 protected:
100 };
101 
102 #endif /*ENCODEEXCEPTION_H_*/
Definition: EncodeException.h:17
Definition: EncodeException.h:15
virtual std::string toString() const
Definition: EncodeException.h:39
Definition: EncodeException.h:16
virtual EncodeException::ErrorCode getErrorCode()
Definition: EncodeException.h:52
Definition: EncodeException.h:18
ErrorCode
Definition: EncodeException.h:11
Definition: EncodeException.h:19
Definition: LibCryptoSecException.h:8
std::string where
Definition: LibCryptoSecException.h:23
Definition: EncodeException.h:22
EncodeException(EncodeException::ErrorCode errorCode, std::string where)
Definition: EncodeException.h:29
Definition: EncodeException.h:8
virtual ~EncodeException()
Definition: EncodeException.h:34
Definition: EncodeException.h:20
virtual std::string getMessage() const
Definition: EncodeException.h:35
Definition: EncodeException.h:13
Definition: EncodeException.h:21
Definition: EncodeException.h:14
static std::string errorCode2Message(EncodeException::ErrorCode errorCode)
Definition: EncodeException.h:56
EncodeException::ErrorCode errorCode
Definition: EncodeException.h:99
EncodeException(std::string where)
Definition: EncodeException.h:24