RFFGen
 All Classes Namespaces Files Functions Typedefs Enumerations Groups
exceptions.hh
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the C++-library RFFGen. */
4 /* Copyright 2015 Lars Lubkoll */
5 /* */
6 /* RFFGen is free software: you can redistribute it and/or modify */
7 /* it under the terms of the GNU General Public License as published by */
8 /* the Free Software Foundation, either version 3 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* RFFGen is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU General Public License */
17 /* along with RFFGen. If not, see <http://www.gnu.org/licenses/>. */
18 /* */
19 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
20 
21 #ifndef RFFGEN_UTIL_EXCEPTIONS_HH
22 #define RFFGEN_UTIL_EXCEPTIONS_HH
23 
24 #include <stdexcept>
25 #include <string>
26 #include <type_traits>
27 
28 namespace RFFGen
29 {
40  class OutOfDomainException : public std::runtime_error
41  {
42  public:
52  template <class Value, class = std::enable_if_t<std::is_arithmetic<Value>::value> >
53  OutOfDomainException(const std::string& function, const std::string& range, const Value& value, const std::string& file, const int line) :
54  std::runtime_error(std::string("OutOfDomainException in ") + file + " at line " + std::to_string(line) + ".\n " + function + ": Argument " + std::to_string(value) + " is outside range " + range + ".\n")
55  {}
56  };
57 
62  class NonSymmetricMatrixException : public std::runtime_error{
63  public:
73  template <class Value, class = std::enable_if_t<std::is_arithmetic<Value>::value> >
74  NonSymmetricMatrixException(const std::string& function, const Value& rows, const Value& cols, const std::string& file, const int line) :
75  std::runtime_error(std::string("NonSymmetricMatrixException in ") + file + " at line " + std::to_string(line) + ".\n " + function + ": Matrix of dimension " + std::to_string(rows) +
76  "x" + std::to_string(cols) + " is not symmetric.\n")
77  {}
78  };
79 }
80 
81 #endif // RFFGEN_UTIL_EXCEPTIONS_HH
OutOfDomainException(const std::string &function, const std::string &range, const Value &value, const std::string &file, const int line)
Constructor.
Definition: exceptions.hh:53
Exception for non-symmetric matrices if symmetric matrices are required.
Definition: exceptions.hh:62
Exception for scalar function arguments that are outside the domain of the function.
Definition: exceptions.hh:40
NonSymmetricMatrixException(const std::string &function, const Value &rows, const Value &cols, const std::string &file, const int line)
Constructor.
Definition: exceptions.hh:74