bpp-core  2.2.0
ParameterExceptions.cpp
Go to the documentation of this file.
1 //
2 // File: ParameterExceptions.cpp
3 // Created by: Julien Dutheil
4 // Created on: Mon Nov 3 18:05:36 2003
5 //
6 
7 /*
8 Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
9 
10 This software is a computer program whose purpose is to provide classes
11 for numerical calculus.
12 
13 This software is governed by the CeCILL license under French law and
14 abiding by the rules of distribution of free software. You can use,
15 modify and/ or redistribute the software under the terms of the CeCILL
16 license as circulated by CEA, CNRS and INRIA at the following URL
17 "http://www.cecill.info".
18 
19 As a counterpart to the access to the source code and rights to copy,
20 modify and redistribute granted by the license, users are provided only
21 with a limited warranty and the software's author, the holder of the
22 economic rights, and the successive licensors have only limited
23 liability.
24 
25 In this respect, the user's attention is drawn to the risks associated
26 with loading, using, modifying and/or developing or reproducing the
27 software by the user in light of its specific status of free software,
28 that may mean that it is complicated to manipulate, and that also
29 therefore means that it is reserved for developers and experienced
30 professionals having in-depth computer knowledge. Users are therefore
31 encouraged to load and test the software's suitability as regards their
32 requirements in conditions enabling the security of their systems and/or
33 data to be ensured and, more generally, to use and operate it in the
34 same conditions as regards security.
35 
36 The fact that you are presently reading this means that you have had
37 knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #include "ParameterExceptions.h"
41 #include "Parameter.h"
42 
43 // From Utils:
44 #include "../Text/TextTools.h"
45 
46 using namespace bpp;
47 using namespace std;
48 
49 /******************************************************************************/
50 
51 ParameterException::ParameterException(const std::string& text, const Parameter* param) :
52  Exception("ParameterException: " + text + (param != 0 ? "(" + param -> getName() + ")" : string(""))),
53  parameter_(param) {};
54 
56 
57 /******************************************************************************/
58 
59 ConstraintException::ConstraintException(const std::string& text, const Parameter* param, double badValue) :
60  ParameterException("ConstraintException: " + text + "(" + TextTools::toString(badValue) + ")"
61  + (param->hasConstraint() ? param->getConstraint()->getDescription() : "no constraint"), param),
62  badValue_(badValue) {};
63 
64 double ConstraintException::getBadValue() const { return badValue_; }
65 
66 /******************************************************************************/
67 
68 ParameterNotFoundException::ParameterNotFoundException(const string& text, const string& param) :
69  Exception("ParameterNotFoundException: " + text + (!TextTools::isEmpty(param) ? "(" + param + ")" : string(""))),
70  parameter_(param) {};
71 
73 
74 /******************************************************************************/
75 
ConstraintException(const std::string &text, const Parameter *param, double badValue)
Build a new ConstraintException object.
ParameterException(const std::string &text, const Parameter *param)
Build a new ParameterException object.
const Parameter * parameter_
This class allows to perform a correspondence analysis.
ParameterNotFoundException(const std::string &text, const std::string &param="")
Build a new ParameterNotFoundException object.
STL namespace.
This class is designed to facilitate the manipulation of parameters.
Definition: Parameter.h:135
virtual double getBadValue() const
Get the value that doesn't match the constraint.
Exception base class.
Definition: Exceptions.h:57
virtual const Parameter * getParameter() const
Get the parameter that threw the exception.
Some utilitary functions that work on strings.
Definition: TextTools.h:58
The parameter exception base class.
virtual std::string getParameter() const
Get the name of the parameter not found.