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
6
7#include "PhyloBranch.h"
8#include "PhyloNode.h"
9#include "PhyloTree.h"
10#include "PhyloTreeExceptions.h"
11
12using namespace bpp;
13using namespace std;
14
15/******************************************************************************/
16
17PhyloNodePException::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
23PhyloNodePException::PhyloNodePException(const std::string& text, const PhyloNode* node) :
24 PhyloNodeException(text, 0), node_(node)
25{}
26
27/******************************************************************************/
28
29PhyloNodeNotFoundException::PhyloNodeNotFoundException(const std::string& text, const std::string& id) :
30 Exception("NodeNotFoundException: " + text + "(" + id + ")"),
31 id_(id) {}
32
34 Exception("NodeNotFoundException: " + text + "(" + TextTools::toString(id) + ")"),
35 id_(TextTools::toString(id)) {}
36
37/******************************************************************************/
38
39PhyloBranchPException::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
45PhyloBranchPException::PhyloBranchPException(const std::string& text, const PhyloBranch* branch) :
46 PhyloBranchException(text, 0), branch_(branch)
47{}
48
49/******************************************************************************/
50
51PhyloBranchNotFoundException::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
63PhyloTreeException::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.