File: errors.cpp

package info (click to toggle)
iqtree 2.0.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 14,620 kB
  • sloc: cpp: 142,571; ansic: 57,789; sh: 275; python: 242; makefile: 95
file content (48 lines) | stat: -rw-r--r-- 1,764 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <terraces/errors.hpp>

namespace terraces {

namespace {

std::string build_error_message(bad_input_error_type type) {
	switch (type) {
	case bad_input_error_type::nwk_mismatched_quotes:
		return "Mismatching quotes in nwk tree";
	case bad_input_error_type::nwk_mismatched_parentheses:
		return "Mismatching parentheses in nwk tree";
	case bad_input_error_type::nwk_taxon_unknown:
		return "Unknown taxon in nwk tree";
	case bad_input_error_type::nwk_taxon_duplicate:
		return "Duplicate taxon in nwk tree";
	case bad_input_error_type::nwk_multifurcating:
		return "Only bifurcating trees are supported";
	case bad_input_error_type::nwk_malformed:
		return "Malformed nwk tree";
	case bad_input_error_type::nwk_tree_trivial:
		return "Less than 4 taxa in nwk tree";
	case bad_input_error_type::bitmatrix_name_duplicate:
		return "Duplicate taxon in bitmatrix ";
	case bad_input_error_type::bitmatrix_name_empty:
		return "Empty taxon name in bitmatrix";
	case bad_input_error_type::bitmatrix_size_invalid:
		return "Mismatching number of rows/columns "
		       "between bitmatrix header and content";
	case bad_input_error_type::bitmatrix_malformed:
		return "Malformed bitmatrix";
	case bad_input_error_type::tree_mismatching_size:
		return "Mismatching size between tree and bitmatrix";
	case bad_input_error_type::tree_unnamed_leaf:
		return "Unnamed leaf found in tree";
	}
	return "Unknown error";
}

} // anonymous namespace

bad_input_error::bad_input_error(bad_input_error_type type)
        : std::runtime_error{build_error_message(type)}, m_type{type} {}

bad_input_error::bad_input_error(bad_input_error_type type, std::string msg)
        : std::runtime_error{build_error_message(type) + "\n" + msg}, m_type{type} {}

} // namespace terraces