-
Notifications
You must be signed in to change notification settings - Fork 1
/
MathExceptions.hpp
93 lines (84 loc) · 1.97 KB
/
MathExceptions.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
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
#ifndef MathExceptions_hpp__
#define MathExceptions_hpp__
#include "MathDefines.h"
#include <exception>
#include <cassert>
MATH_START
MATH_BASIC_START
class GeneralException : std::exception
{
public :
enum class Type : char { InvalidParams = 0 };
GeneralException(GeneralException::Type CrtType) : std::exception(ToString(CrtType))
{
}
private :
const char* ToString(GeneralException::Type CrtType)
{
switch (CrtType)
{
case Type::InvalidParams :
return "InvalidParams";
default :
{
assert(false && L"Not covered...");
return "GeneralException unknown";
}
}
}
};
class StorageException : std::exception
{
public :
enum class Type : char { WrongMatrixType = 0, InvalidDimsForOperation, InvalidIndex, InvalidMemoryAcces };
StorageException(StorageException::Type CrtType) : std::exception(ToString(CrtType))
{
}
private :
const char* ToString(StorageException::Type CrtType)
{
switch (CrtType)
{
case Type::WrongMatrixType :
return "WrongMatrixType";
case Type::InvalidDimsForOperation :
return "InvalidDimsForOperation";
case Type::InvalidIndex :
return "InvalidIndex";
case Type::InvalidMemoryAcces :
return "InvalidMemoryAcces";
default :
{
assert(false && L"Not covered...");
return "StorageException unknown";
}
}
}
};
class MatrixException : std::exception
{
public :
enum class Type : char { NonSquareMatrix = 0, SingularMatrix};
MatrixException(MatrixException::Type CrtType) : std::exception(ToString(CrtType))
{
}
private :
const char* ToString(MatrixException::Type CrtType)
{
switch (CrtType)
{
case Type::NonSquareMatrix :
return "NonSquareMatrix";
case Type::SingularMatrix :
return "SingularMatrix";
default :
{
assert(false && L"Not covered...");
return "MatrixException unknown";
}
}
}
};
MATH_BASIC_END
MATH_END
#endif // MathExceptions_hpp__