Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
exceptions.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Logger.h> // IWYU pragma: keep
35#include <ogdf/basic/basic.h>
36#include <ogdf/basic/internal/config_autogen.h>
37
38#include <exception>
39#include <iostream> // IWYU pragma: keep
40
41namespace ogdf {
42
45
47#define OGDF_FLUSH_OUTPUTS std::cout << std::flush, ::ogdf::Logger::sfout() << std::flush
48
58#define OGDF_THROW_PARAM(CLASS, PARAM) OGDF_FLUSH_OUTPUTS, throw CLASS(PARAM)
59
67#define OGDF_THROW(CLASS) OGDF_FLUSH_OUTPUTS, throw CLASS()
68
69#ifdef OGDF_DEBUG
70# undef OGDF_THROW_PARAM
71# define OGDF_THROW_PARAM(CLASS, PARAM) \
72 OGDF_FLUSH_OUTPUTS, throw CLASS(PARAM, __FILE__, __LINE__)
73# undef OGDF_THROW
74# define OGDF_THROW(CLASS) OGDF_FLUSH_OUTPUTS, throw CLASS(__FILE__, __LINE__)
75#endif
76
78
80
86 Unknown,
88 NoFlow,
89 Sort,
90 Label,
96
97 // The following codes are used by Abacus (think about changing them to
98 // more error describing codes)
100 DualBound,
102 Buffer,
103 AddVar,
104 Sorter,
105 Phase,
106 Active,
109 Guarantee,
111 Strategy,
112 CloseHalf,
114 Variable,
115 LpIf,
116 Lp,
117 Bstack,
118 LpStatus,
120 FixSet,
121 LpSub,
122 String,
124 Pool,
125 Global,
126 FsVarStat,
127 LpVarStat,
128 OsiIf,
130 Timer,
131 Array,
132 Csense,
134 FixCand,
135 BHeap,
136 Poolslot,
137 SparVec,
138 Convar,
139 Ostream,
140 Hash,
142 InfeasCon,
143
144 STOP // INSERT NEW CODES BEFORE afcSTOP!
145};
146
148
153 Unknown,
154 Coin,
155 Abacus,
156 Cgal,
159 STOP // INSERT NEW CODES BEFORE nscSTOP!
160};
161
163
166class OGDF_EXPORT Exception : std::exception {
167private:
168 const char* m_file;
169 int m_line;
170
171public:
173
177 explicit Exception(const char* file = nullptr, int line = -1) : m_file(file), m_line(line) { }
178
180
183 const char* file() const { return m_file; }
184
186
189 int line() const { return m_line; }
190
191 const char* what() const noexcept override { return "Unknown OGDF Exception"; }
192};
193
195
199public:
201 explicit DynamicCastFailedException(const char* file = nullptr, int line = -1)
202 : Exception(file, line) { }
203};
204
206
210public:
212 explicit InsufficientMemoryException(const char* file = nullptr, int line = -1)
213 : Exception(file, line) { }
214};
215
217
226public:
228 explicit NoStdComparerException(const char* file = nullptr, int line = -1)
229 : Exception(file, line) { }
230};
231
233
237public:
239 explicit TypeNotSupportedException(const char* file = nullptr, int line = -1)
240 : Exception(file, line) { }
241};
242
244
248public:
250 explicit AlgorithmFailureException(AlgorithmFailureCode code, const char* file = nullptr,
251 int line = -1)
252 : Exception(file, line), m_exceptionCode(code) { }
253
255 explicit AlgorithmFailureException(const char* file = nullptr, int line = -1)
256 : Exception(file, line), m_exceptionCode(AlgorithmFailureCode::Unknown) { }
257
259 AlgorithmFailureCode exceptionCode() const { return m_exceptionCode; }
260
261 const char* what() const noexcept override { return codeToString(m_exceptionCode); }
262
263 static const char* codeToString(AlgorithmFailureCode code);
264
265private:
267};
268
270
274public:
276 explicit LibraryNotSupportedException(LibraryNotSupportedCode code, const char* file = nullptr,
277 int line = -1)
278 : Exception(file, line), m_exceptionCode(code) { }
279
281 explicit LibraryNotSupportedException(const char* file = nullptr, int line = -1)
282 : Exception(file, line), m_exceptionCode(LibraryNotSupportedCode::Unknown) { }
283
285 LibraryNotSupportedCode exceptionCode() const { return m_exceptionCode; }
286
287private:
289};
290
291}
Contains logging functionality.
Basic declarations, included by all source files.
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing.
Definition exceptions.h:247
AlgorithmFailureCode m_exceptionCode
The error code specifying the exception.
Definition exceptions.h:266
AlgorithmFailureCode exceptionCode() const
Returns the error code of the exception.
Definition exceptions.h:259
static const char * codeToString(AlgorithmFailureCode code)
AlgorithmFailureException(const char *file=nullptr, int line=-1)
Constructs an algorithm failure exception.
Definition exceptions.h:255
const char * what() const noexcept override
Definition exceptions.h:261
AlgorithmFailureException(AlgorithmFailureCode code, const char *file=nullptr, int line=-1)
Constructs an algorithm failure exception.
Definition exceptions.h:250
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:219
Exception thrown when result of cast is 0.
Definition exceptions.h:198
DynamicCastFailedException(const char *file=nullptr, int line=-1)
Constructs a dynamic cast failed exception.
Definition exceptions.h:201
Base class of all ogdf exceptions.
Definition exceptions.h:166
const char * m_file
Source file where exception occurred.
Definition exceptions.h:168
int m_line
Line number where exception occurred.
Definition exceptions.h:169
Exception(const char *file=nullptr, int line=-1)
Constructs an exception.
Definition exceptions.h:177
const char * what() const noexcept override
Definition exceptions.h:191
int line() const
Returns the line number where the exception was thrown.
Definition exceptions.h:189
const char * file() const
Returns the name of the source file where exception was thrown.
Definition exceptions.h:183
Exception thrown when not enough memory is available to execute an algorithm.
Definition exceptions.h:209
InsufficientMemoryException(const char *file=nullptr, int line=-1)
Constructs an insufficient memory exception.
Definition exceptions.h:212
Exception thrown when an external library shall be used which is not supported.
Definition exceptions.h:273
LibraryNotSupportedCode exceptionCode() const
Returns the error code of the exception.
Definition exceptions.h:285
LibraryNotSupportedCode m_exceptionCode
The error code specifying the exception.
Definition exceptions.h:288
LibraryNotSupportedException(const char *file=nullptr, int line=-1)
Constructs a library not supported exception.
Definition exceptions.h:281
LibraryNotSupportedException(LibraryNotSupportedCode code, const char *file=nullptr, int line=-1)
Constructs a library not supported exception.
Definition exceptions.h:276
Exception thrown when a required standard comparer has not been specialized.
Definition exceptions.h:225
NoStdComparerException(const char *file=nullptr, int line=-1)
Constructs a no standard comparer available exception.
Definition exceptions.h:228
Exception thrown when a data type is not supported by a generic function.
Definition exceptions.h:236
TypeNotSupportedException(const char *file=nullptr, int line=-1)
Constructs a type-not-supported exception.
Definition exceptions.h:239
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
AlgorithmFailureCode
Code for an internal failure condition.
Definition exceptions.h:85
LibraryNotSupportedCode
Code for the library which was intended to get used, but its use is not supported.
Definition exceptions.h:152
@ IndexOutOfBounds
index out of bounds
@ ExternalFace
external face not correct
@ ForbiddenCrossing
crossing forbidden but necessary
@ NoFlow
min-cost flow could not find a legal flow
@ Sort
sequence not sorted
@ NoSolutionFound
couldn't solve the problem
@ Label
labelling failed
@ IllegalParameter
function parameter is illegal
@ TimelimitExceeded
it took too long
@ FunctionNotImplemented
the used library doesn't support that function
@ Abacus
ABACUS not supported.
@ Cgal
CGAL not supported.
@ Coin
COIN not supported.
The namespace for all OGDF objects.