Open
Graph Drawing
Framework

 v. 2022.02 (Dogwood)
 

exceptions.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/basic.h>
35 #include <ogdf/basic/Logger.h>
36 
37 namespace ogdf {
38 
41 
43 #define OGDF_FLUSH_OUTPUTS \
44  std::cout << std::flush, ::ogdf::Logger::sfout() << std::flush
45 
55 #define OGDF_THROW_PARAM(CLASS, PARAM) \
56  OGDF_FLUSH_OUTPUTS, throw CLASS(PARAM)
57 
65 #define OGDF_THROW(CLASS) \
66  OGDF_FLUSH_OUTPUTS, throw CLASS()
67 
68 #ifdef OGDF_DEBUG
69 # undef OGDF_THROW_PARAM
70 # define OGDF_THROW_PARAM(CLASS, PARAM) \
71  OGDF_FLUSH_OUTPUTS, throw CLASS(PARAM, __FILE__, __LINE__)
72 # undef OGDF_THROW
73 # define OGDF_THROW(CLASS) \
74  OGDF_FLUSH_OUTPUTS, throw CLASS(__FILE__, __LINE__)
75 #endif
76 
78 
80 
86  Unknown,
88  NoFlow,
89  Sort,
90  Label,
91  ExternalFace,
96 
97  // The following codes are used by Abacus (think about changing them to
98  // more error describing codes)
100  DualBound,
101  NotInteger,
102  Buffer,
103  AddVar,
104  Sorter,
105  Phase,
106  Active,
107  NoSolution,
108  MakeFeasible,
109  Guarantee,
111  Strategy,
112  CloseHalf,
113  StandardPool,
114  Variable,
115  LpIf,
116  Lp,
117  Bstack,
118  LpStatus,
120  FixSet,
121  LpSub,
122  String,
123  Constraint,
124  Pool,
125  Global,
126  FsVarStat,
127  LpVarStat,
128  OsiIf,
130  Timer,
131  Array,
132  Csense,
133  BPrioQueue,
134  FixCand,
135  BHeap,
136  Poolslot,
137  SparVec,
138  Convar,
139  Ostream,
140  Hash,
141  Paramaster,
142  InfeasCon,
143 
144  STOP // INSERT NEW CODES BEFORE afcSTOP!
145 };
146 
148 
153  Unknown,
154  Coin,
155  Abacus,
158  STOP // INSERT NEW CODES BEFORE nscSTOP!
159 };
160 
162 
166 
167 private:
168 
169  const char *m_file;
170  int m_line;
171 
172 public:
174 
178  explicit Exception(const char *file = nullptr, int line = -1) :
179  m_file(file),
180  m_line(line)
181  { }
182 
184 
187  const char *file() const { return m_file; }
188 
190 
193  int line() const { return m_line; }
194 };
195 
196 
198 
202 
203 public:
205  explicit DynamicCastFailedException(const char *file = nullptr, int line = -1) : Exception(file, line) {}
206 };
207 
208 
210 
214 
215 public:
217  explicit InsufficientMemoryException(const char *file = nullptr, int line = -1) : Exception(file, line) {}
218 };
219 
220 
222 
231 
232 public:
234  explicit NoStdComparerException(const char *file = nullptr, int line = -1) : Exception(file, line) {}
235 };
236 
237 
239 
243 
244 public:
246  explicit TypeNotSupportedException(const char *file = nullptr, int line = -1) : Exception(file, line) {}
247 };
248 
250 
254 {
255 public:
256 
259  const char *file = nullptr,
260  int line = -1) :
261  Exception(file, line),
262  m_exceptionCode(code)
263  {}
264 
267  const char *file = nullptr,
268  int line = -1) :
269  Exception(file, line),
270  m_exceptionCode(AlgorithmFailureCode::Unknown)
271  {}
272 
274  AlgorithmFailureCode exceptionCode() const { return m_exceptionCode; }
275 
276 private:
278 };
279 
281 
285  public:
288  const char *file = nullptr,
289  int line = -1) :
290  Exception(file, line),
291  m_exceptionCode(code)
292  {}
293 
296  const char *file = nullptr,
297  int line = -1) :
298  Exception(file, line),
299  m_exceptionCode(LibraryNotSupportedCode::Unknown)
300  {}
301 
303  LibraryNotSupportedCode exceptionCode() const { return m_exceptionCode; }
304 
305 private:
307 };
308 
309 }
ogdf::Exception::Exception
Exception(const char *file=nullptr, int line=-1)
Constructs an exception.
Definition: exceptions.h:178
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:230
ogdf::Exception
Base class of all ogdf exceptions.
Definition: exceptions.h:165
ogdf::LibraryNotSupportedCode::MissingCallbackImplementation
@ MissingCallbackImplementation
ogdf::AlgorithmFailureCode::Lp
@ Lp
ogdf::DynamicCastFailedException
Exception thrown when result of cast is 0.
Definition: exceptions.h:201
ogdf::AlgorithmFailureException::AlgorithmFailureException
AlgorithmFailureException(const char *file=nullptr, int line=-1)
Constructs an algorithm failure exception.
Definition: exceptions.h:266
ogdf::AlgorithmFailureCode::Global
@ Global
ogdf::InsufficientMemoryException
Exception thrown when not enough memory is available to execute an algorithm.
Definition: exceptions.h:213
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:205
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:277
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:169
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:303
ogdf::LibraryNotSupportedException::LibraryNotSupportedException
LibraryNotSupportedException(LibraryNotSupportedCode code, const char *file=nullptr, int line=-1)
Constructs a library not supported exception.
Definition: exceptions.h:287
ogdf::AlgorithmFailureException
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing.
Definition: exceptions.h:253
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:152
ogdf::LibraryNotSupportedCode::Abacus
@ Abacus
ABACUS 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:187
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:217
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:234
ogdf::AlgorithmFailureException::exceptionCode
AlgorithmFailureCode exceptionCode() const
Returns the error code of the exception.
Definition: exceptions.h:274
ogdf::LibraryNotSupportedCode::Unknown
@ Unknown
ogdf::AlgorithmFailureCode::InfeasCon
@ InfeasCon
ogdf::AlgorithmFailureCode::Sorter
@ Sorter
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:306
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:99
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:242
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:258
ogdf::AlgorithmFailureCode::StandardPool
@ StandardPool
ogdf::LibraryNotSupportedException
Exception thrown when an external library shall be used which is not supported.
Definition: exceptions.h:284
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:295
ogdf::Exception::m_line
int m_line
Line number where exception occurred.
Definition: exceptions.h:170
ogdf::Exception::line
int line() const
Returns the line number where the exception was thrown.
Definition: exceptions.h:193
ogdf::AlgorithmFailureCode
AlgorithmFailureCode
Code for an internal failure condition.
Definition: exceptions.h:85
ogdf::TypeNotSupportedException::TypeNotSupportedException
TypeNotSupportedException(const char *file=nullptr, int line=-1)
Constructs a type-not-supported exception.
Definition: exceptions.h:246
ogdf::AlgorithmFailureCode::ExternalFace
@ ExternalFace
external face not correct
ogdf::AlgorithmFailureCode::LpVarStat
@ LpVarStat