YAP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Exceptions.h
Go to the documentation of this file.
1 /* YAP - Yet another PWA toolkit
2  Copyright 2015, Technische Universitaet Muenchen,
3  Authors: Daniel Greenwald, Johannes Rauch
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
20 
21 #ifndef yap_Exceptions_h
22 #define yap_Exceptions_h
23 
24 #include <stdexcept>
25 #include <string>
26 
27 namespace yap {
28 
29 namespace exceptions {
30 
39 struct Exception : public std::exception {
40 public:
44  Exception(const std::string& what_arg, const std::string& func_name) : std::exception(),
45  What_(what_arg),
46  Func_(func_name)
47  {}
48 
49  void addFunc(const std::string& s) noexcept
50  { Func_ += (Func_.empty() ? "" : " < ") + s; }
51 
52  const char* what() const noexcept override
53  { return (What_ + (What_.empty() or Func_.empty() ? "" : " ") + (Func_.empty() ? "" : std::string("from ") + Func_)).data(); }
54 
55 protected:
56  Exception() : std::exception() {}
57  std::string What_;
58  std::string Func_;
59 };
60 
64 {
65 public:
66  AngularMomentumNotConserved(const std::string& func_name)
67  : Exception("Angular momentum not conserved", func_name) {}
68 };
69 
73 {
74 public:
75  InconsistentSpinProjection(const std::string& what_arg, const std::string& func_name)
76  : Exception(what_arg, func_name) {}
77 };
78 
82 {
83 public:
84  OutsidePhaseSpace(const std::string& what_arg = "", const std::string& func_name = "FourMomenta::setSquaredMasses")
85  : Exception(what_arg, func_name) {}
86 };
87 
91 {
92 public:
93  NotTwoBodyParticleCombination(const std::string& what_arg = "", const std::string& func_name = "")
94  : Exception(what_arg, func_name) {}
95 };
96 
100 {
101 public:
102  ParameterIsFixed(const std::string& what_arg = "", const std::string& func_name = "")
103  : Exception(what_arg, func_name) {}
104 };
105 
108 class ResonanceUnset : public Exception
109 {
110 public:
111  ResonanceUnset(const std::string& func_name = "")
112  : Exception("Resonance unset", func_name) {}
113 };
114 
117 class NonfiniteResult : public Exception {};
118 
122 {
123 public:
124  InconsistentDataPoint(const std::string& func_name = "")
125  : Exception("Inconsistent DataPoint", func_name) {}
126 };
127 
131 {
132 public:
133  EmptyFourMomentaVector(const std::string& func_name = "")
134  : Exception("Empty FourMomenta vector", func_name) {}
135 };
136 
137 }
138 
139 }
140 
141 #endif
Definition: Exceptions.h:117
Definition: Exceptions.h:130
Definition: Exceptions.h:108
Definition: Exceptions.h:121
Base class for handling YAP exceptions.
Definition: Exceptions.h:39
Definition: Exceptions.h:81
Exception(const std::string &what_arg, const std::string &func_name)
Definition: Exceptions.h:44
Definition: Exceptions.h:99