bpp-phyl3  3.0.0
PhyloTreeExceptions.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #include <Bpp/Text/TextTools.h>
6 
7 #include "PhyloBranch.h"
8 #include "PhyloNode.h"
9 #include "PhyloTree.h"
10 #include "PhyloTreeExceptions.h"
11 
12 using namespace bpp;
13 using namespace std;
14 
15 /******************************************************************************/
16 
17 PhyloNodePException::PhyloNodePException(const std::string& text, const PhyloTree& tree, const std::shared_ptr<PhyloNode> node) :
18  PhyloNodeException(text, tree.getNodeIndex(node)), node_(node.get())
19 {}
20 
21 /******************************************************************************/
22 
23 PhyloNodePException::PhyloNodePException(const std::string& text, const PhyloNode* node) :
24  PhyloNodeException(text, 0), node_(node)
25 {}
26 
27 /******************************************************************************/
28 
29 PhyloNodeNotFoundException::PhyloNodeNotFoundException(const std::string& text, const std::string& id) :
30  Exception("NodeNotFoundException: " + text + "(" + id + ")"),
31  id_(id) {}
32 
33 PhyloNodeNotFoundException::PhyloNodeNotFoundException(const std::string& text, uint id) :
34  Exception("NodeNotFoundException: " + text + "(" + TextTools::toString(id) + ")"),
35  id_(TextTools::toString(id)) {}
36 
37 /******************************************************************************/
38 
39 PhyloBranchPException::PhyloBranchPException(const std::string& text, const PhyloTree& tree, const std::shared_ptr<PhyloBranch> branch) :
40  PhyloBranchException(text, tree.getEdgeIndex(branch)), branch_(branch.get())
41 {}
42 
43 /******************************************************************************/
44 
45 PhyloBranchPException::PhyloBranchPException(const std::string& text, const PhyloBranch* branch) :
46  PhyloBranchException(text, 0), branch_(branch)
47 {}
48 
49 /******************************************************************************/
50 
51 PhyloBranchNotFoundException::PhyloBranchNotFoundException(const std::string& text, const std::string& id) :
52  Exception("BranchNotFoundException: " + text + "(" + id + ")"),
53  id_(id) {}
54 
55 /******************************************************************************/
56 
58  Exception("BranchNotFoundException: " + text + "(" + TextTools::toString(id) + ")"),
59  id_(TextTools::toString(id)) {}
60 
61 /******************************************************************************/
62 
63 PhyloTreeException::PhyloTreeException(const std::string& text, const PhyloTree* tree) :
64  Exception("PhyloTreeException: " + text + (tree != 0 ? "(" + tree->getName() + ")" : "")),
65  tree_(tree) {}
66 
67 /******************************************************************************/
68 
70  PhyloTreeException("UnrootedPhyloTreeException: " + text, tree) {}
71 
72 /******************************************************************************/
General exception thrown when something is wrong with a particular branch.
PhyloBranchNotFoundException(const std::string &text, const std::string &id)
Build a new PhyloBranchNotFoundException.
PhyloBranchPException(const std::string &text, const PhyloTree &tree, const std::shared_ptr< PhyloBranch > branch)
Build a new PhyloBranchPException.
General exception thrown when something is wrong with a particular node.
PhyloNodeNotFoundException(const std::string &text, const std::string &id)
Build a new PhyloNodeNotFoundException.
PhyloNodePException(const std::string &text, const PhyloTree &tree, const std::shared_ptr< PhyloNode > node)
Build a new PhyloNodePException.
General exception thrown when something wrong happened in a tree.
PhyloTreeException(const std::string &text, const PhyloTree *tree=0)
Build a new PhyloTreeException.
UnrootedPhyloTreeException(const std::string &text, const PhyloTree *tree=0)
Build a new UnrootedPhyloTreeException.
std::string toString(T t)
Defines the basic types of data flow nodes.