SIde-Channel Analysis toolKit (SICAK)
Software toolkit for side-channel analysis
exceptions.hpp
Go to the documentation of this file.
1 /*
2 * SICAK - SIde-Channel Analysis toolKit
3 * Copyright (C) 2018 Petr Socha, FIT, CTU in Prague
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18 
29 #ifndef EXCEPTIONS_HPP
30 #define EXCEPTIONS_HPP
31 
32 #include <exception>
33 #include <string>
34 
35 
36 
43 class Exception : public std::exception {
44 
45 public:
46 
48  Exception() : m_msg("Unspecified error") {}
50  Exception(const char * msg, int errCode = 0) : m_msg(msg) {
51  if(errCode){
52  m_msg.append(", error code: ");
53  m_msg.append(std::to_string(errCode));
54  }
55  }
56 
58  virtual const char * what() const throw () {
59  return m_msg.c_str();
60  }
61 
62 protected:
63 
65  std::string m_msg;
66 
67 };
68 
69 
76 class RuntimeException : public Exception {
77 
78 public:
82  RuntimeException(const char * msg, int errCode = 0) : Exception(msg, errCode) {}
83 
84 };
85 
86 
94 
95 public:
99  InvalidInputException(const char * msg, int errCode = 0) : Exception(msg, errCode) {}
100 
101 };
102 
103 
104 #endif /* EXCEPTIONS_HPP */
virtual const char * what() const
Return the error message, potentially with error code included.
Definition: exceptions.hpp:58
RuntimeException()
Constructor with a default error message.
Definition: exceptions.hpp:80
Exception()
Constructor with a default error message.
Definition: exceptions.hpp:48
RuntimeException(const char *msg, int errCode=0)
Constructor with a custom error message and error code.
Definition: exceptions.hpp:82
An exception caused by bad settings of input parameters or arguments.
Definition: exceptions.hpp:93
InvalidInputException(const char *msg, int errCode=0)
Constructor with a custom error message and error code.
Definition: exceptions.hpp:99
InvalidInputException()
Constructor with a default error message.
Definition: exceptions.hpp:97
A base exception.
Definition: exceptions.hpp:43
std::string m_msg
Error message.
Definition: exceptions.hpp:65
Exception(const char *msg, int errCode=0)
Constructor with a custom error message and error code.
Definition: exceptions.hpp:50
An exception which cannot be directly influenced by the user, or predicted beforehand.
Definition: exceptions.hpp:76