KASKADE 7 development version
detailed_exception.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the library KASKADE 7 */
4/* https://www.zib.de/research/projects/kaskade7-finite-element-toolbox */
5/* */
6/* Copyright (C) 2012-2019 Zuse Institute Berlin */
7/* */
8/* KASKADE 7 is distributed under the terms of the ZIB Academic License. */
9/* see $KASKADE/academic.txt */
10/* */
11/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12#ifndef DETAILED_EXCEPTION_HH
13#define DETAILED_EXCEPTION_HH
14
15#include <string>
16#include <stdexcept>
17#include <boost/lexical_cast.hpp>
18
19namespace Kaskade{
34 class DetailedException : public std::runtime_error{
35 public:
36 DetailedException(std::string const& message, std::string const& file, int const line) :
37 std::runtime_error(std::string("Exception in ") + file + " at line " + boost::lexical_cast<std::string>(line) + ".\n" + message)
38 {
39 }
40 };
41
47 {
48 public:
49 IOException(std::string const& message, std::string const& file, int const line) :
50 DetailedException(message,file,line)
51 {
52 }
53 };
54
60 {
61 public:
62 FileIOException(std::string const& message, std::string const& filename_, std::string const& file, int const line) :
63 IOException(std::string("File I/O exception for file ") + filename_ + ".\n" + message,file,line), filename(filename_)
64 {
65 }
66
67 std::string filename;
68 };
69
75 {
76 public:
77 LookupException (std::string const& message, std::string const& file, int const line):
78 DetailedException(std::string("Key lookup failed:\n")+message,file,line)
79 {
80 }
81 };
82
88 {
89 public:
90 LinearAlgebraException(std::string const& message, std::string const& file, int const line) :
91 DetailedException(std::string("Linear algebra failure:\n")+message,file,line)
92 {
93 }
94 };
95
101 {
102 public:
103 NonpositiveMatrixException(std::string const& message, std::string const& file, int const line) :
104 LinearAlgebraException(std::string("Matrix is not positive definite:\n")+message,file,line)
105 {
106 }
107 };
108
114 {
115 public:
116 SingularMatrixException(std::string const& message, std::string const& file, int const line):
117 LinearAlgebraException(std::string("Matrix is singular.\n")+message,file,line)
118 {
119 }
120 };
121
127 {
128 public:
129 NonsquareMatrixException(std::string const& message, std::string const& file, int const line):
130 LinearAlgebraException(std::string("Matrix is nonsquare.\n")+message,file,line)
131 {
132 }
133 };
134
142 {
143 public:
144 DirectSolverException(std::string const& message, std::string const& file, int const line):
145 LinearAlgebraException(std::string("Direct solver failed.\n")+message,file,line)
146 {
147 }
148 };
149
155 {
156 public:
157 IterativeSolverException(std::string const& message, std::string const& file, int const line):
158 DetailedException(std::string("Iterative solver failed.\n")+message,file,line)
159 {
160 }
161 };
162
168 {
169 public:
170 InfeasibleProblemException(std::string const& message, std::string const& file, int const line):
171 IterativeSolverException(std::string("Problem has no solution (infeasible).\n")+message,file,line)
172 {
173 }
174 };
175
181 {
182 public:
183 UnboundedProblemException(std::string const& message, std::string const& file, int const line):
184 IterativeSolverException(std::string("Optimization problem has no solution (unbounded).\n")+message,file,line)
185 {
186 }
187 };
188
194 {
195 public:
196 LinesearchException(std::string const& message, std::string const& file, int const line):
197 IterativeSolverException(std::string("Linesearch failed.\n")+message,file,line)
198 {
199 }
200 };
201
207 {
208 public:
209 GridException(std::string const& message, std::string const& file, int const line) :
210 DetailedException("Grid error.\n"+message,file,line)
211 {
212 }
213 };
214
215
216}
217
218#endif
A wrapper class for conveniently providing exceptions with context information.
DetailedException(std::string const &message, std::string const &file, int const line)
To be raised if a direct solver fails.
DirectSolverException(std::string const &message, std::string const &file, int const line)
An exception class for file IO errors.
FileIOException(std::string const &message, std::string const &filename_, std::string const &file, int const line)
An exception class for grid related errors.
GridException(std::string const &message, std::string const &file, int const line)
An exception class for IO errors.
IOException(std::string const &message, std::string const &file, int const line)
To be raised if an iterative solver detects the problem to be infeasible (has no valid solution).
InfeasibleProblemException(std::string const &message, std::string const &file, int const line)
To be raised if an iterative solver fails.
IterativeSolverException(std::string const &message, std::string const &file, int const line)
A base class for linear algebra exceptions.
LinearAlgebraException(std::string const &message, std::string const &file, int const line)
To be raised if a linesearch fails.
LinesearchException(std::string const &message, std::string const &file, int const line)
An exception that can be thrown whenever a key lookup fails.
LookupException(std::string const &message, std::string const &file, int const line)
To be raised if the matrix is not positive definite.
NonpositiveMatrixException(std::string const &message, std::string const &file, int const line)
To be raised if the matrix is nonsquare.
NonsquareMatrixException(std::string const &message, std::string const &file, int const line)
To be raised if the matrix is singular.
SingularMatrixException(std::string const &message, std::string const &file, int const line)
To be raised if an iterative solver detects the optimization problem to be unbounded (has no valid so...
UnboundedProblemException(std::string const &message, std::string const &file, int const line)