-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmultigrid_exceptions.hpp
59 lines (46 loc) · 1.48 KB
/
multigrid_exceptions.hpp
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
/*
multigrid_expections (Multigrid)
Jess Robertson, 2011-01-28
Basic exception classes for multigrid
*/
#ifndef MULTIGRID_EXCEPTIONS_HPP_6MQVVDHT
#define MULTIGRID_EXCEPTIONS_HPP_6MQVVDHT
#include <iostream>
namespace mgrid {
enum MessageType {ErrorMessage, WarningMessage, StatusMessage};
class Message: public std::ostringstream {
public:
Message(MessageType messageType) {
switch (messageType) {
case ErrorMessage:
(*this) << " *ERROR* ";
break;
case WarningMessage:
(*this) << " Warning ";
break;
case StatusMessage:
(*this) << " ----> ";
break;
}
}
};
class MultigridException: public std::exception {};
class BoundaryLengthException: public MultigridException {
public:
virtual const char* what() const throw() {
Message msg(ErrorMessage);
msg << "Lengths of arrays supplied to boundary conditions "
<< "are different.";
return msg.str().c_str();
}
};
class InvalidBoundaryCondition: public MultigridException {
public:
virtual const char* what() const throw() {
Message msg(ErrorMessage);
msg << "A boundary condition of the wrong length was supplied.";
return msg.str().c_str();
}
};
} // end namespace mgrid
#endif /* end of include guard: MULTIGRID_EXCEPTIONS_HPP_6MQVVDHT */