Desafio Labsec (SGC)
IoException.h
Go to the documentation of this file.
1 #ifndef IOEXCEPTION_H
2 #define IOEXCEPTION_H
3 
4 #include <libcryptosec/exception/LibCryptoSecException.h>
5 
16 class IoException : public LibCryptoSecException {
17 
18 public:
19  enum ErrorCode {
23  };
24 
25  IoException(std::string where)
26  {
27  this->where = where;
29  }
30 
32  {
33  this->where = where;
34  this->errorCode = errorCode;
35  }
36 
37  ~IoException() throw () {}
38 
39  virtual std::string getMessage() const
40  {
42  }
43 
44 
45  virtual std::string toString() const
46  {
47  return "IoException: " + IoException::errorCode2Message(this->errorCode) + ". Called by: " + this->where + ".";
48  }
49 
51  {
52  return this->errorCode;
53  }
54 
55 
57  {
58  std::string ret;
59  switch (errorCode)
60  {
62  ret = "Unknown error";
63  break;
65  ret = "Failed to read file";
66  break;
68  ret = "Failed to write file";
69  break;
70  }
71  return ret;
72  }
73 
74 protected:
76 
77 };
78 #endif /*IOEXCEPTION*/
IoException::ErrorCode errorCode
Definition: IoException.h:75
~IoException()
Definition: IoException.h:37
ErrorCode
Definition: IoException.h:19
Definition: IoException.h:21
IoException(std::string where)
Definition: IoException.h:25
IoException(std::string where, IoException::ErrorCode errorCode)
Definition: IoException.h:31
Definition: IoException.h:20
virtual IoException::ErrorCode getErrorCode()
Definition: IoException.h:50
virtual std::string toString() const
Definition: IoException.h:45
static std::string errorCode2Message(IoException::ErrorCode errorCode)
Definition: IoException.h:56
I/O Exception
Definition: IoException.h:16
virtual std::string getMessage() const
Definition: IoException.h:39
Definition: IoException.h:22