-
Notifications
You must be signed in to change notification settings - Fork 0
/
exceptions.hh
102 lines (92 loc) · 2.27 KB
/
exceptions.hh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef EXCEPTIONS_HH
#define EXCEPTIONS_HH
/*!
* \file exceptions.hh
* \brief Common exceptions in Quill
*/
#include <sstream>
#include <Exception.hh>
//! %Exception thrown when an element data file could not be opened
struct NoFile: public Li::Exception
{
//! Constructor
NoFile(const std::string& fname):
Exception("Unable to open file \"" + fname + "\"") {}
};
//! %Exception throw when the end of the input is reached unexpectedly
struct UnexpectedEOF: public Li::Exception
{
//! Constructor
UnexpectedEOF(): Exception("Unexpected end of file") {}
};
/*!
* \brief %Exception thrown when trying to look up an element not listed
* in the periodic table
*/
struct UnknownElement: public Li::Exception
{
//! Constructor
UnknownElement(const std::string& elem):
Exception("Unknown element \"" + elem + "\"") {}
//! Constructor
UnknownElement(int number): Exception()
{
std::ostringstream os;
os << number;
setMsg("Unknown element " + number);
}
};
//! %Exception thrown when an errors occurs while parsing input
struct ParseError: public Li::Exception
{
//! Constructor
ParseError(): Exception("Parse error") {}
//! Constructor
ParseError(const std::string& msg): Exception("Parse error: " + msg) {}
};
/*!
* \brief %Exception thrown when trying to access a container element
* using an index not present in the container
*/
struct InvalidIndex: public Li::Exception
{
//! Constructor
template <typename T>
InvalidIndex(T t): Exception()
{
std::ostringstream os;
os << "Invalid index " << t;
setMsg(os.str());
}
//! Constructor
InvalidIndex(size_t i, size_t j): Exception()
{
std::ostringstream os;
os << "Invalid index " << i << ", " << j;
setMsg(os.str());
}
};
/*!
* \brief %Exception thrown when trying to create an orbital with higher
* angular momentum than Quill supports
*/
struct ShellTooHigh: public Li::Exception
{
//! Constructor
ShellTooHigh(int l): Exception()
{
std::ostringstream os;
os << "Orbital shell " << l << " is higher than supported";
setMsg(os.str());
}
};
/*!
* \brief %Exception thrown when no convergence could be reached in an
* iterative calculation
*/
struct NoConvergence: public Li::Exception
{
//! Constructor
NoConvergence(): Exception("Unable to reach convergence") {}
};
#endif // EXCEPTIONS_HH