retdec
config_exceptions.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_CONFIG_CONFIG_EXCEPTIONS_H
8 #define RETDEC_CONFIG_CONFIG_EXCEPTIONS_H
9 
10 #include <exception>
11 #include <string>
12 
13 namespace retdec {
14 namespace config {
15 
19 class Exception : public std::exception
20 {
21 };
22 
28 class ParseException : public Exception
29 {
30  public:
32  const std::string& message,
33  std::size_t line,
34  std::size_t column)
35  :
36  _message(message),
37  _line(line),
38  _column(column),
40  " @ line = " + std::to_string(_line) +
41  ", column = " + std::to_string(_column))
42  {
43  }
44 
45  std::string getMessage() const
46  {
47  return _message;
48  }
49 
50  std::size_t getLine() const
51  {
52  return _line;
53  }
54 
55  std::size_t getColumn() const
56  {
57  return _column;
58  }
59 
64  virtual const char* what() const noexcept override
65  {
66  return _whatMessage.c_str();
67  }
68 
69  private:
71  std::string _message;
73  std::size_t _line = 0;
75  std::size_t _column = 0;
77  std::string _whatMessage;
78 };
79 
85 {
86  public:
87  FileNotFoundException(const std::string& message) :
88  _whatMessage(message)
89  {
90 
91  }
92 
93  virtual const char* what() const noexcept override
94  {
95  return _whatMessage.c_str();
96  }
97 
98  private:
100  std::string _whatMessage;
101 };
102 
103 } // namespace config
104 } // namespace retdec
105 
106 #endif
Definition: config_exceptions.h:20
Definition: config_exceptions.h:85
std::string _whatMessage
Message returned by what() method.
Definition: config_exceptions.h:100
FileNotFoundException(const std::string &message)
Definition: config_exceptions.h:87
virtual const char * what() const noexcept override
Definition: config_exceptions.h:93
Definition: config_exceptions.h:29
std::string _whatMessage
Message returned by what() method.
Definition: config_exceptions.h:77
std::size_t _line
Line in JSON where error occurred.
Definition: config_exceptions.h:73
virtual const char * what() const noexcept override
Definition: config_exceptions.h:64
ParseException(const std::string &message, std::size_t line, std::size_t column)
Definition: config_exceptions.h:31
std::string _message
Error message.
Definition: config_exceptions.h:71
std::string getMessage() const
Definition: config_exceptions.h:45
std::size_t getColumn() const
Definition: config_exceptions.h:55
std::size_t _column
Column in JSON where error occurred.
Definition: config_exceptions.h:75
std::size_t getLine() const
Definition: config_exceptions.h:50
Definition: archive_wrapper.h:19