BCESolve
bceexception.hpp
1// This file is part of the BCESolve library for games of incomplete
2// information
3// Copyright (C) 2022 Benjamin A. Brooks
4//
5// BCESolve free software: you can redistribute it and/or modify it
6// 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// BCESolve is distributed in the hope that it will be useful, but
11// WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13// 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
17// <http://www.gnu.org/licenses/>.
18//
19// Benjamin A. Brooks
20// ben@benjaminbrooks.net
21// Chicago, IL
22
23#ifndef BCEEXCEPTION_HPP
24#define BCEEXCEPTION_HPP
25
27
32class BCEException: public std::exception
33{
34public:
37 {
59 WrongWeightSize,
61 };
62
65
67
68 BCEException(ErrorType errorTypeArg): errorType(errorTypeArg)
69 { }
70
72 const char* what() const throw()
73 {
74 return "BCEException was thrown";
75 }
76
78
79 string getMessage()
80 {
81 switch (errorType)
82 {
83 case OutOfBounds:
84 return "An index was out of the provided bounds.";
85 case ConditionFailed:
86 return "A condition we imposed failed.";
88 return "A condition we imposed in bcecounter.cpp failed.";
90 return "A condition we imposed in bceabstractgame.cpp failed.";
91 case NoEquilibria:
92 return "There are no equilibria.";
94 return "Map frontier is not optimal.";
95 case FailedOpen:
96 return "The file failed to open.";
97 case NotProbDistr:
98 return "Probabilities are misbehaving. At least one is negative or greater than 1, or they do not sum to 1.";
99 case BadArgument:
100 return "A bad argument was received.";
102 return "A bad argument was received in bcecomparator.cpp.";
104 return "A bad argument was received in bceutilities.cpp.";
106 return "A bad argument was received in bceabstractgame.cpp.";
108 return "Parameter name wasn't recognized.";
110 return "A parameter value is invalid.";
112 return "An incentive constraint was violated.";
113 case WrongDistnSize:
114 return "Distribution given in solution data does not reflect the correct number of actions.";
115 case WrongWeightSize:
116 return "Size of the weight vector supplied as an argument to BCESolver::solve(weights) does not match the number of objectives. Check your specification in the example file.";
117 case AlreadyPopulated:
118 return "Solver is already populated.";
119 } // switch
120 }
121};
122
123#endif
Exception class for BCESolve.
Definition: bceexception.hpp:33
string getMessage()
Returns an error message.
Definition: bceexception.hpp:79
ErrorType errorType
Gives the error code for this BCEException.
Definition: bceexception.hpp:64
const char * what() const
Reimplements std::exception::what().
Definition: bceexception.hpp:72
ErrorType
Type of error.
Definition: bceexception.hpp:37
@ AlreadyPopulated
Definition: bceexception.hpp:60
@ InvalidParameterName
Definition: bceexception.hpp:55
@ BadArgumentBCEAbstractGame
Definition: bceexception.hpp:54
@ BCEAbstractGameConditionFailed
Definition: bceexception.hpp:41
@ OutOfBounds
Definition: bceexception.hpp:38
@ ConditionFailed
Definition: bceexception.hpp:39
@ BadArgumentBCEUtilities
Definition: bceexception.hpp:53
@ MapFrontierNotOptimal
Definition: bceexception.hpp:45
@ NotProbDistr
Definition: bceexception.hpp:50
@ WrongDistnSize
Definition: bceexception.hpp:58
@ BadArgumentBCEComparator
Definition: bceexception.hpp:52
@ FailedOpen
Definition: bceexception.hpp:46
@ BCECounterConditionFailed
Definition: bceexception.hpp:40
@ ICConstraintViolated
Definition: bceexception.hpp:57
@ InvalidParameterValue
Definition: bceexception.hpp:56
@ BadArgument
Definition: bceexception.hpp:51
@ NoEquilibria
Definition: bceexception.hpp:42
BCEException(ErrorType errorTypeArg)
Constructor.
Definition: bceexception.hpp:68