bpp-core3  3.0.0
Exceptions.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_EXCEPTIONS_H
6 #define BPP_EXCEPTIONS_H
7 
8 #include <array>
9 #include <stdexcept>
10 #include <string>
11 
12 
13 namespace bpp
14 {
20 class Exception : public std::exception
21 {
22 private:
23  std::string message_;
24 
25 public:
32  Exception(std::string text, int stack = 10);
36  const char* what() const noexcept override;
38  const std::string& message() const noexcept;
39 };
40 
42 class IOException : public Exception
43 {
44 public:
49  IOException(std::string text);
50 };
51 
57 {
58 public:
63  NullPointerException(std::string text);
64 };
65 
68 {
69 public:
73  ZeroDivisionException(std::string text);
74 };
75 
78 {
79 private:
80  int badInt_;
81 
82 public:
87  BadIntegerException(std::string text, int badInt);
91  int getBadInteger() const;
92 };
93 
96 {
97 private:
98  double badNumber_;
99 
100 public:
105  BadNumberException(std::string text, double badNumber);
109  double getBadNumber() const;
110 };
111 
114 {
115 private:
116  std::string badNumber_;
117 
118 public:
123  NumberFormatException(std::string text, std::string badNumber);
127  const std::string& getBadNumber() const;
128 };
129 
132 {
133 private:
134  std::size_t badIndex_;
135  std::array<std::size_t, 2> bounds_;
136 
137 public:
144  IndexOutOfBoundsException(std::string text, std::size_t badInt, std::size_t lowerBound, std::size_t upperBound);
146  const std::array<std::size_t, 2>& getBounds() const;
147  std::size_t getBadIndex() const;
148 };
149 
152 {
153 private:
154  std::size_t badSize_;
155  std::size_t correctSize_;
156 
157 public:
163  BadSizeException(std::string text, std::size_t badSize, std::size_t correctSize);
164 
165  std::size_t getBadSize() const;
166  std::size_t getCorrectSize() const;
167 };
168 
171 {
172 private:
173  double badValue_;
174  std::array<double, 2> bounds_;
175 
176 public:
183  OutOfRangeException(std::string text, double badValue, double lowerBound, double upperBound);
184 
185  double getBadValue () const;
186  double getLowerBound() const;
187  double getUpperBound() const;
188 };
189 
192 {
193 public:
197  NotImplementedException(std::string text);
198 };
199 } // namespace bpp
200 #endif // BPP_EXCEPTIONS_H
Number exception: doubles.
Definition: Exceptions.h:95
const std::string & message() const noexcept
Access the message as a std::string.
Definition: Exceptions.cpp:79
The base class exception for zero division error.
Definition: Exceptions.h:67
The base class exception for IO error.
Definition: Exceptions.h:42
Exception(std::string text, int stack=10)
Build a new Exception.
Definition: Exceptions.cpp:16
const char * what() const noexcept override
Method to get the message of the exception (STL method redefinition).
Definition: Exceptions.cpp:78
Number exception: integers.
Definition: Exceptions.h:77
std::size_t badSize_
Definition: Exceptions.h:154
std::array< double, 2 > bounds_
Definition: Exceptions.h:174
STL namespace.
std::size_t correctSize_
Definition: Exceptions.h:155
Wrong size exception class.
Definition: Exceptions.h:151
This exception is sent when a given method is not implemented.
Definition: Exceptions.h:191
std::string message_
Definition: Exceptions.h:23
std::array< std::size_t, 2 > bounds_
Definition: Exceptions.h:135
The base class exception for NULL pointer error. This exception may be thrown when an unexpected NULL...
Definition: Exceptions.h:56
Out of range exception class.
Definition: Exceptions.h:170
Exception base class. Overload exception constructor (to control the exceptions mechanism). Destructor is already virtual (from std::exception)
Definition: Exceptions.h:20
Number format exception.
Definition: Exceptions.h:113
Index out of bounds exception class.
Definition: Exceptions.h:131