libcryptosec
HmacException.h
Go to the documentation of this file.
1 #ifndef HMACEXCEPTION_H_
2 #define HMACEXCEPTION_H_
3 
5 
7 
8 public:
9  enum ErrorCode {
15  };
16 
17  HmacException(std::string where)
18  {
19  this->where = where;
21  }
22 
24  {
25  this->where = where;
26  this->errorCode = errorCode;
27  }
28 
29  ~HmacException() throw () {}
30 
31  virtual std::string getMessage() const
32  {
34  }
35 
36  virtual std::string toString() const
37  {
38  std::string ret;
39  if (this->errorCode == HmacException::UNKNOWN)
40  {
41  ret = "HmacException. Called by: " + this->where + ".";
42  }
43  else
44  {
45  ret = "HmacException: " + HmacException::errorCode2Message(this->errorCode) + ". Called by: " + this->where + ".";
46  }
47  return ret;
48  }
49 
51  {
52  return this->errorCode;
53  }
54 
56  {
57  std::string ret;
58  switch (errorCode)
59  {
61  ret = "Unknown error";
62  break;
64  ret = "Invalid message digest algorithm";
65  break;
67  ret = "Creating hmac context";
68  break;
70  ret = "Updating hmac context";
71  break;
73  ret = "Finishing hmac context";
74  break;
75  }
76  return ret;
77  }
78 
79 protected:
81 
82 };
83 
84 #endif
Definition: HmacException.h:6
Definition: MessageDigestException.h:11
Definition: HmacException.h:12
Definition: MessageDigestException.h:14
ErrorCode
Definition: HmacException.h:9
static std::string errorCode2Message(HmacException::ErrorCode errorCode)
Definition: HmacException.h:55
Definition: HmacException.h:14
Definition: HmacException.h:11
Definition: MessageDigestException.h:15
Definition: MessageDigestException.h:12
HmacException(HmacException::ErrorCode errorCode, std::string where)
Definition: HmacException.h:23
Definition: HmacException.h:13
Definition: LibCryptoSecException.h:8
std::string where
Definition: LibCryptoSecException.h:23
virtual std::string getMessage() const
Definition: HmacException.h:31
Definition: MessageDigestException.h:13
virtual HmacException::ErrorCode getErrorCode()
Definition: HmacException.h:50
~HmacException()
Definition: HmacException.h:29
HmacException(std::string where)
Definition: HmacException.h:17
Definition: HmacException.h:10
virtual std::string toString() const
Definition: HmacException.h:36
HmacException::ErrorCode errorCode
Definition: HmacException.h:80