Linopt
Linear optics circuit calculator
exceptions.h
1 /* Copyright © 2018, 2019, Quantum Optical Technologies Laboratories
2  * <https://www.qotlabs.org/en/>
3  * Contributed by: Struchalin Gleb <struchalin.gleb@physics.msu.ru>
4  * Dyakonov Ivan <iv.dyakonov@physics.msu.ru>
5  *
6  * This file is part of Linopt.
7  *
8  * Linopt is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * Linopt is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with Linopt. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
26 #ifndef EXCEPTIONS_H
27 #define EXCEPTIONS_H
28 
29 #include <string>
30 #include <stdexcept>
31 
32 namespace linopt
33 {
34 
35 inline std::string formatErrorMessage(std::string msg, const char *func)
36 {
37  return std::string() + "linopt::" + func + "(): " + msg;
38 }
39 
40 #define ERROR_MSG(...) formatErrorMessage(__VA_ARGS__, __func__)
41 
48 class GeneralError: public std::logic_error
49 {
50  using logic_error::logic_error;
51 };
52 
57 class WrongSize: public GeneralError
58 {
59  using GeneralError::GeneralError;
60 };
61 
66 class NotUnitary : public GeneralError
67 {
68  using GeneralError::GeneralError;
69 };
70 
72 {
73  using GeneralError::GeneralError;
74 };
75 
76 } // Namespace linopt
77 
78 #endif // EXCEPTIONS_H
The main namespace containing all library classes, functions, etc.
Definition: circuit.h:28
The base exception class.
Definition: exceptions.h:48
The object of this type is thrown when a unitary matrix is expected, but it is not.
Definition: exceptions.h:66
The object of this type is thrown when an object of improper size is encountered. ...
Definition: exceptions.h:57
Definition: exceptions.h:71