-
Notifications
You must be signed in to change notification settings - Fork 1
/
error.h
73 lines (59 loc) · 1.81 KB
/
error.h
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
#ifndef _ERROR_H_
#define _ERROR_H_
#include <exception>
#include <string>
using namespace std;
namespace Renzoku {
void throw_error(const char *error, const char *file, int line);
void throw_warning(const char *warn, const char *file, int line);
void error_alloc(const char *file, int line);
void error_file(const char *file, int line, const char *filename);
class BaseException : public std::exception {
public:
BaseException() : s("") {}
BaseException(string s) : s(s) {}
virtual ~BaseException() throw() {}
virtual const char *what() const throw() {
return s.c_str();
}
protected:
string s;
};
/**
* TypeException is thrown when a type is passed into a template class
* but it is not fully supported.
*
* For example, when an arbitrary object
* is passed into Matrix<T> class, the load/save function does not work
* as it does not know how to load/save the type T.
* Therefore, this exception must be thrown when the load/save is called
* on the unknown type.
*/
class TypeException : public BaseException {
public:
TypeException(string s) : BaseException(s) {}
};
class FileException : public BaseException {
public:
FileException(string s) : BaseException(s) {}
};
/**
* NotEnoughCapacityException is thrown when a matrix fails to expand its rows
* due to the maximum capacity of the matrix is reached.
*
* New allocation of matrix internal data is required.
*/
class NotEnoughCapacityException : public BaseException {
public:
NotEnoughCapacityException(string s) : BaseException(s) {}
};
/**
* IncompatibleSizeException is thrown when an operation that requires two vectors
* with the same size is called but the input is not.
*/
class IncompatibleSizeException : public BaseException {
public:
IncompatibleSizeException() {}
};
} // end namespace
#endif