Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

exceptions.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Logger.h>
35 #include <ogdf/basic/basic.h>
36 
37 namespace ogdf {
38 
41 
43 #define OGDF_FLUSH_OUTPUTS std::cout << std::flush, ::ogdf::Logger::sfout() << std::flush
44 
54 #define OGDF_THROW_PARAM(CLASS, PARAM) OGDF_FLUSH_OUTPUTS, throw CLASS(PARAM)
55 
63 #define OGDF_THROW(CLASS) OGDF_FLUSH_OUTPUTS, throw CLASS()
64 
65 #ifdef OGDF_DEBUG
66 # undef OGDF_THROW_PARAM
67 # define OGDF_THROW_PARAM(CLASS, PARAM) \
68  OGDF_FLUSH_OUTPUTS, throw CLASS(PARAM, __FILE__, __LINE__)
69 # undef OGDF_THROW
70 # define OGDF_THROW(CLASS) OGDF_FLUSH_OUTPUTS, throw CLASS(__FILE__, __LINE__)
71 #endif
72 
74 
76 
82  Unknown,
84  NoFlow,
85  Sort,
86  Label,
87  ExternalFace,
92 
93  // The following codes are used by Abacus (think about changing them to
94  // more error describing codes)
96  DualBound,
97  NotInteger,
98  Buffer,
99  AddVar,
100  Sorter,
101  Phase,
102  Active,
103  NoSolution,
104  MakeFeasible,
105  Guarantee,
107  Strategy,
108  CloseHalf,
109  StandardPool,
110  Variable,
111  LpIf,
112  Lp,
113  Bstack,
114  LpStatus,
116  FixSet,
117  LpSub,
118  String,
119  Constraint,
120  Pool,
121  Global,
122  FsVarStat,
123  LpVarStat,
124  OsiIf,
126  Timer,
127  Array,
128  Csense,
129  BPrioQueue,
130  FixCand,
131  BHeap,
132  Poolslot,
133  SparVec,
134  Convar,
135  Ostream,
136  Hash,
137  Paramaster,
138  InfeasCon,
139 
140  STOP // INSERT NEW CODES BEFORE afcSTOP!
141 };
142 
144 
149  Unknown,
150  Coin,
151  Abacus,
152  Cgal,
155  STOP // INSERT NEW CODES BEFORE nscSTOP!
156 };
157 
159 
162 class OGDF_EXPORT Exception : std::exception {
163 private:
164  const char* m_file;
165  int m_line;
166 
167 public:
169 
173  explicit Exception(const char* file = nullptr, int line = -1) : m_file(file), m_line(line) { }
174 
176 
179  const char* file() const { return m_file; }
180 
182 
185  int line() const { return m_line; }
186 
187  const char* what() const noexcept override { return "Unknown OGDF Exception"; }
188 };
189 
191 
195 public:
197  explicit DynamicCastFailedException(const char* file = nullptr, int line = -1)
198  : Exception(file, line) { }
199 };
200 
202 
206 public:
208  explicit InsufficientMemoryException(const char* file = nullptr, int line = -1)
209  : Exception(file, line) { }
210 };
211 
213 
222 public:
224  explicit NoStdComparerException(const char* file = nullptr, int line = -1)
225  : Exception(file, line) { }
226 };
227 
229 
233 public:
235  explicit TypeNotSupportedException(const char* file = nullptr, int line = -1)
236  : Exception(file, line) { }
237 };
238 
240 
244 public:
246  explicit AlgorithmFailureException(AlgorithmFailureCode code, const char* file = nullptr,
247  int line = -1)
248  : Exception(file, line), m_exceptionCode(code) { }
249 
251  explicit AlgorithmFailureException(const char* file = nullptr, int line = -1)
252  : Exception(file, line), m_exceptionCode(AlgorithmFailureCode::Unknown) { }
253 
255  AlgorithmFailureCode exceptionCode() const { return m_exceptionCode; }
256 
257  const char* what() const noexcept override { return codeToString(m_exceptionCode); }
258 
259  static const char* codeToString(AlgorithmFailureCode code);
260 
261 private:
263 };
264 
266 
270 public:
272  explicit LibraryNotSupportedException(LibraryNotSupportedCode code, const char* file = nullptr,
273  int line = -1)
274  : Exception(file, line), m_exceptionCode(code) { }
275 
277  explicit LibraryNotSupportedException(const char* file = nullptr, int line = -1)
278  : Exception(file, line), m_exceptionCode(LibraryNotSupportedCode::Unknown) { }
279 
281  LibraryNotSupportedCode exceptionCode() const { return m_exceptionCode; }
282 
283 private:
285 };
286 
287 }
ogdf::Exception::Exception
Exception(const char *file=nullptr, int line=-1)
Constructs an exception.
Definition: exceptions.h:173
ogdf::AlgorithmFailureCode::BranchingVariable
@ BranchingVariable
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::AlgorithmFailureCode::BranchingRule
@ BranchingRule
ogdf::NoStdComparerException
Exception thrown when a required standard comparer has not been specialized.
Definition: exceptions.h:221
ogdf::Exception
Base class of all ogdf exceptions.
Definition: exceptions.h:162
ogdf::LibraryNotSupportedCode::MissingCallbackImplementation
@ MissingCallbackImplementation
ogdf::AlgorithmFailureCode::Lp
@ Lp
ogdf::DynamicCastFailedException
Exception thrown when result of cast is 0.
Definition: exceptions.h:194
ogdf::AlgorithmFailureException::AlgorithmFailureException
AlgorithmFailureException(const char *file=nullptr, int line=-1)
Constructs an algorithm failure exception.
Definition: exceptions.h:251
ogdf::AlgorithmFailureCode::Global
@ Global
ogdf::InsufficientMemoryException
Exception thrown when not enough memory is available to execute an algorithm.
Definition: exceptions.h:205
ogdf::AlgorithmFailureCode::Sort
@ Sort
sequence not sorted
ogdf::AlgorithmFailureCode::CloseHalf
@ CloseHalf
ogdf::AlgorithmFailureCode::Label
@ Label
labelling failed
ogdf::AlgorithmFailureCode::NoSolution
@ NoSolution
ogdf::LibraryNotSupportedCode::STOP
@ STOP
ogdf::AlgorithmFailureCode::LpIf
@ LpIf
ogdf::AlgorithmFailureCode::ForbiddenCrossing
@ ForbiddenCrossing
crossing forbidden but necessary
ogdf::AlgorithmFailureCode::NotInteger
@ NotInteger
ogdf::DynamicCastFailedException::DynamicCastFailedException
DynamicCastFailedException(const char *file=nullptr, int line=-1)
Constructs a dynamic cast failed exception.
Definition: exceptions.h:197
ogdf::AlgorithmFailureCode::LpStatus
@ LpStatus
ogdf::AlgorithmFailureCode::Unknown
@ Unknown
ogdf::AlgorithmFailureCode::NoFlow
@ NoFlow
min-cost flow could not find a legal flow
ogdf::AlgorithmFailureException::m_exceptionCode
AlgorithmFailureCode m_exceptionCode
The error code specifying the exception.
Definition: exceptions.h:262
ogdf::AlgorithmFailureCode::Ostream
@ Ostream
ogdf::AlgorithmFailureCode::FixSet
@ FixSet
ogdf::AlgorithmFailureCode::Hash
@ Hash
ogdf::Exception::m_file
const char * m_file
Source file where exception occurred.
Definition: exceptions.h:164
Logger.h
Contains logging functionality.
ogdf::AlgorithmFailureCode::LpSub
@ LpSub
ogdf::AlgorithmFailureCode::String
@ String
ogdf::LibraryNotSupportedException::exceptionCode
LibraryNotSupportedCode exceptionCode() const
Returns the error code of the exception.
Definition: exceptions.h:281
ogdf::LibraryNotSupportedException::LibraryNotSupportedException
LibraryNotSupportedException(LibraryNotSupportedCode code, const char *file=nullptr, int line=-1)
Constructs a library not supported exception.
Definition: exceptions.h:272
ogdf::AlgorithmFailureException
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing.
Definition: exceptions.h:243
ogdf::AlgorithmFailureCode::Csense
@ Csense
ogdf::LibraryNotSupportedCode
LibraryNotSupportedCode
Code for the library which was intended to get used, but its use is not supported.
Definition: exceptions.h:148
ogdf::LibraryNotSupportedCode::Abacus
@ Abacus
ABACUS not supported.
ogdf::LibraryNotSupportedCode::Cgal
@ Cgal
CGAL not supported.
ogdf::AlgorithmFailureCode::Guarantee
@ Guarantee
ogdf::Exception::file
const char * file() const
Returns the name of the source file where exception was thrown.
Definition: exceptions.h:179
ogdf::AlgorithmFailureCode::Constraint
@ Constraint
ogdf::AlgorithmFailureCode::MakeFeasible
@ MakeFeasible
ogdf::AlgorithmFailureCode::Strategy
@ Strategy
ogdf::AlgorithmFailureCode::BPrioQueue
@ BPrioQueue
ogdf::AlgorithmFailureCode::OsiIf
@ OsiIf
ogdf::AlgorithmFailureCode::Array
@ Array
ogdf::AlgorithmFailureCode::DualBound
@ DualBound
ogdf::AlgorithmFailureCode::Convar
@ Convar
ogdf::InsufficientMemoryException::InsufficientMemoryException
InsufficientMemoryException(const char *file=nullptr, int line=-1)
Constructs an insufficient memory exception.
Definition: exceptions.h:208
ogdf::AlgorithmFailureCode::AddVar
@ AddVar
ogdf::AlgorithmFailureCode::Active
@ Active
ogdf::AlgorithmFailureCode::Timer
@ Timer
ogdf::NoStdComparerException::NoStdComparerException
NoStdComparerException(const char *file=nullptr, int line=-1)
Constructs a no standard comparer available exception.
Definition: exceptions.h:224
ogdf::AlgorithmFailureException::exceptionCode
AlgorithmFailureCode exceptionCode() const
Returns the error code of the exception.
Definition: exceptions.h:255
ogdf::LibraryNotSupportedCode::Unknown
@ Unknown
ogdf::AlgorithmFailureCode::InfeasCon
@ InfeasCon
ogdf::AlgorithmFailureCode::Sorter
@ Sorter
ogdf::Exception::what
const char * what() const noexcept override
Definition: exceptions.h:187
ogdf::AlgorithmFailureCode::PrimalBound
@ PrimalBound
ogdf::AlgorithmFailureCode::TimelimitExceeded
@ TimelimitExceeded
it took too long
ogdf::AlgorithmFailureCode::Pool
@ Pool
ogdf::AlgorithmFailureCode::Bstack
@ Bstack
ogdf::LibraryNotSupportedException::m_exceptionCode
LibraryNotSupportedCode m_exceptionCode
The error code specifying the exception.
Definition: exceptions.h:284
ogdf::AlgorithmFailureCode::Paramaster
@ Paramaster
ogdf::AlgorithmFailureCode::BHeap
@ BHeap
ogdf::AlgorithmFailureCode::NoSolutionFound
@ NoSolutionFound
couldn't solve the problem
ogdf::AlgorithmFailureCode::Variable
@ Variable
basic.h
Basic declarations, included by all source files.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::AlgorithmFailureCode::FsVarStat
@ FsVarStat
ogdf::AlgorithmFailureCode::SparVec
@ SparVec
ogdf::AlgorithmFailureCode::IllegalParameter
@ IllegalParameter
function parameter is illegal
ogdf::AlgorithmFailureCode::Phase
@ Phase
ogdf::TypeNotSupportedException
Exception thrown when a data type is not supported by a generic function.
Definition: exceptions.h:232
ogdf::AlgorithmFailureCode::Poolslot
@ Poolslot
ogdf::AlgorithmFailureCode::IndexOutOfBounds
@ IndexOutOfBounds
index out of bounds
ogdf::AlgorithmFailureCode::Buffer
@ Buffer
ogdf::AlgorithmFailureException::AlgorithmFailureException
AlgorithmFailureException(AlgorithmFailureCode code, const char *file=nullptr, int line=-1)
Constructs an algorithm failure exception.
Definition: exceptions.h:246
ogdf::AlgorithmFailureCode::StandardPool
@ StandardPool
ogdf::AlgorithmFailureException::what
const char * what() const noexcept override
Definition: exceptions.h:257
ogdf::LibraryNotSupportedException
Exception thrown when an external library shall be used which is not supported.
Definition: exceptions.h:269
ogdf::LibraryNotSupportedCode::FunctionNotImplemented
@ FunctionNotImplemented
the used library doesn't support that function
ogdf::AlgorithmFailureCode::STOP
@ STOP
ogdf::AlgorithmFailureCode::FixCand
@ FixCand
ogdf::LibraryNotSupportedCode::Coin
@ Coin
COIN not supported.
ogdf::AlgorithmFailureCode::ConBranchRule
@ ConBranchRule
ogdf::LibraryNotSupportedException::LibraryNotSupportedException
LibraryNotSupportedException(const char *file=nullptr, int line=-1)
Constructs a library not supported exception.
Definition: exceptions.h:277
ogdf::Exception::m_line
int m_line
Line number where exception occurred.
Definition: exceptions.h:165
ogdf::Exception::line
int line() const
Returns the line number where the exception was thrown.
Definition: exceptions.h:185
ogdf::AlgorithmFailureCode
AlgorithmFailureCode
Code for an internal failure condition.
Definition: exceptions.h:81
ogdf::TypeNotSupportedException::TypeNotSupportedException
TypeNotSupportedException(const char *file=nullptr, int line=-1)
Constructs a type-not-supported exception.
Definition: exceptions.h:235
ogdf::AlgorithmFailureCode::ExternalFace
@ ExternalFace
external face not correct
ogdf::AlgorithmFailureCode::LpVarStat
@ LpVarStat