libcryptosec
BigIntegerException.h
Go to the documentation of this file.
1 #ifndef BIGINTEGEREXCEPTION_H_
2 #define BIGINTEGEREXCEPTION_H_
3 
4 #include <openssl/err.h>
6 
8 {
9 public:
10  enum ErrorCode
11  {
12  UNKNOWN = 0,
17  };
18 
20  {
21  this->where = where;
22  this->errorCode = errorCode;
23  }
24  virtual ~BigIntegerException() throw() {}
25 
26  virtual std::string getMessage() const
27  {
29  }
30 
31  virtual std::string toString() const
32  {
33  std::string ret;
35  {
36  ret = "BigIntegerException. Called by: " + this->where + ".";
37  }
38  else
39  {
40  ret = "BigIntegerException: " + BigIntegerException::errorCode2Message(this->errorCode) + ". Called by: " + this->where + ".";
41  }
42  return ret;
43  }
44 
46  {
47  return this->errorCode;
48  }
49 
51  {
52  std::string ret;
53  switch (errorCode)
54  {
55  case UNKNOWN:
56  ret = "Unknown error";
57  break;
58  case MEMORY_ALLOC:
59  ret = "Memory allocation error";
60  break;
61  case INTERNAL_ERROR:
62  ret = "OpenSSL BIGNUM operation internal error";
63  break;
65  ret = "Big Integer can not be represented as unsigned long";
66  break;
67  case DIVISION_BY_ZERO:
68  ret = "Division by zero";
69  break;
70 
71  }
72  return ret;
73  }
74 
75 protected:
77 };
78 
79 #endif /*BIGINTEGEREXCEPTION_H_*/
ErrorCode errorCode
Definition: BigIntegerException.h:76
Definition: BigIntegerException.h:16
Definition: BigIntegerException.h:13
virtual ~BigIntegerException()
Definition: BigIntegerException.h:24
virtual ErrorCode getErrorCode()
Definition: BigIntegerException.h:45
Definition: BigIntegerException.h:12
ErrorCode
Definition: BigIntegerException.h:10
virtual std::string getMessage() const
Definition: BigIntegerException.h:26
BigIntegerException(ErrorCode errorCode=UNKNOWN, std::string where="")
Definition: BigIntegerException.h:19
Definition: LibCryptoSecException.h:8
std::string where
Definition: LibCryptoSecException.h:23
static std::string errorCode2Message(ErrorCode errorCode)
Definition: BigIntegerException.h:50
Definition: BigIntegerException.h:15
Definition: BigIntegerException.h:7
virtual std::string toString() const
Definition: BigIntegerException.h:31
Definition: BigIntegerException.h:14