2
// File: TreeExceptions.h
3
// Created by: Julien Dutheil
4
// Created on: Mon Nov 3 17:04:46 2003
8
Copyright or Ā© or Copr. CNRS, (November 16, 2004)
10
This software is a computer program whose purpose is to provide classes
11
for phylogenetic data analysis.
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".
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
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.
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.
40
#ifndef _TREEEXCEPTIONS_H_
41
#define _TREEEXCEPTIONS_H_
43
#include <Bpp/Exceptions.h>
44
#include <Bpp/Text/TextTools.h>
55
* @brief General exception thrown when something is wrong with a particular node.
65
* @brief Build a new NodePException.
66
* @param text A message to be passed to the exception hierarchy.
67
* @param nodeId The id of the node that threw the exception.
69
NodeException(const std::string& text, int nodeId) :
70
Exception("NodeException: " + text + "(id:" + TextTools::toString(nodeId) + ")"),
73
virtual ~NodeException() throw () {}
77
* @brief Get the id of node that threw the exception.
79
* @return The id of the faulty node.
81
virtual int getNodeId() const { return nodeId_; }
86
* @brief General exception thrown when something is wrong with a particular node.
88
class NodePException :
96
* @brief Build a new NodePException.
97
* @param text A message to be passed to the exception hierarchy.
98
* @param node A const pointer toward the node that threw the exception.
100
NodePException(const std::string& text, const Node* node = 0);
103
* @brief Build a new NodePException.
104
* @param text A message to be passed to the exception hierarchy.
105
* @param nodeId The id of the node that threw the exception.
107
NodePException(const std::string& text, int nodeId) :
108
NodeException(text, nodeId), node_(0) {}
110
NodePException(const NodePException& nex) :
115
NodePException& operator=(const NodePException& nex)
117
NodeException::operator=(nex);
122
virtual ~NodePException() throw () {}
126
* @brief Get the node that threw the exception.
128
* @return A pointer toward the faulty node.
130
virtual const Node* getNode() const { return node_; };
132
* @brief Get the id of node that threw the exception.
134
* @return The id of the faulty node.
136
virtual int getNodeId() const { return nodeId_; }
140
* @brief General exception thrown if a property could not be found.
142
class PropertyNotFoundException :
143
public NodePException
146
std::string propertyName_;
150
* @brief Build a new PropertyNotFoundException.
152
* @param text A message to be passed to the exception hierarchy.
153
* @param propertyName The name of the property.
154
* @param node A const pointer toward the node that threw the exception.
156
PropertyNotFoundException(const std::string& text, const std::string& propertyName, const Node* node = 0) :
157
NodePException("Property not found: " + propertyName + ". " + text, node),
158
propertyName_(propertyName) {}
161
* @brief Build a new PropertyNotFoundException.
163
* @param text A message to be passed to the exception hierarchy.
164
* @param propertyName The name of the property.
165
* @param nodeId The id of the node that threw the exception.
167
PropertyNotFoundException(const std::string& text, const std::string& propertyName, int nodeId) :
168
NodePException("Property not found: " + propertyName + ". " + text, nodeId),
169
propertyName_(propertyName) {}
171
virtual ~PropertyNotFoundException() throw () {}
175
* @brief Get the name of the property that could not be found.
177
* @return The name of the missing property.
179
virtual const std::string& getPropertyName() const { return propertyName_; }
183
* @brief Exception thrown when something is wrong with a particular node.
185
class NodeNotFoundException :
193
* @brief Build a new NodeNotFoundException.
195
* @param text A message to be passed to the exception hierarchy.
196
* @param id A string describing the node.
198
NodeNotFoundException(const std::string& text, const std::string& id);
201
* @brief Build a new NodeNotFoundException.
203
* @param text A message to be passed to the exception hierarchy.
204
* @param id A node identifier.
206
NodeNotFoundException(const std::string& text, int id);
208
virtual ~NodeNotFoundException() throw () {}
212
* @brief Get the node id that threw the exception.
214
* @return The id of the node.
216
virtual std::string getId() const { return id_; }
220
* @brief General exception thrown when something wrong happened in a tree.
222
class TreeException :
230
* @brief Build a new TreeException.
232
* @param text A message to be passed to the exception hierarchy.
233
* @param tree A const pointer toward the tree that threw the exception.
235
TreeException(const std::string& text, const Tree* tree = 0);
237
TreeException(const TreeException& tex) :
242
TreeException& operator=(const TreeException& tex)
244
Exception::operator=(tex);
249
virtual ~TreeException() throw () {}
253
* @brief Get the tree that threw the exception.
255
* @return The faulty tree
257
virtual const Tree* getTree() const { return tree_; }
261
* @brief Exception thrown when a tree is expected to be rooted.
263
class UnrootedTreeException :
268
* @brief Build a new UnrootedTreeException.
270
* @param text A message to be passed to the exception hierarchy.
271
* @param tree A const pointer toward the tree that threw the exception.
273
UnrootedTreeException(const std::string& text, const Tree* tree = 0);
275
virtual ~UnrootedTreeException() throw () {}
278
} // end of namespace bpp.
280
#endif // _TREEEXCEPTIONS_H_