-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyExceptions.h
More file actions
154 lines (143 loc) · 4.26 KB
/
myExceptions.h
File metadata and controls
154 lines (143 loc) · 4.26 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
* File: myExceptions.h
* Author: tg
*
* Created on November 8, 2013, 10:16 AM
*/
#ifndef MYEXCEPTIONS_H
#define MYEXCEPTIONS_H
#include <sstream>
#include <string>
namespace myExcepts{
/**
* \class myException
* \brief generic exception
*/
class myException {
protected:
const std::string msg_;
public:
myException (const std::string text): msg_ (text) {}
~myException() throw() {}
virtual const std::string what() const throw() =0;
};
/**
* \class FileMissing
* \brief Thrown when expected file could not be opened
*/
class FileMissing: public myException {
public:
FileMissing (const std::string text): myException(text) {}
const std::string what() const throw () {
std::ostringstream msg;
msg << " *** Error: File " << msg_
<< " cannot be opened\n";
return msg.str();
}
};
/**
* \class Keyword
* \brief Thrown when keyword not found in input file
*/
class Keyword: public myException {
public:
Keyword (const std::string text): myException(text) {}
const std::string what() const throw () {
std::ostringstream msg;
msg << " *** Error: Keyword " << msg_
<< " not found\n";
return msg.str();
}
};
/**
* \class FileHeader
* \brief Exception to be thrown for incomplete file header
*/
class FileHeader: public myException {
public:
FileHeader (const std::string text): myException (text) {}
~FileHeader() throw () {}
const std::string what() const throw () {
std::ostringstream msg;
msg << " *** Error: Unexpected or incomplete file header. " << msg_
<< " not found\n";
return msg.str();
}
};
/**
* \class Dimension
* \brief Wrong dimension in initialisation of matrix, vector, etc.
*/
class Dimension: public myException {
public:
Dimension (const std::string text): myException (text) {}
~Dimension() throw () {}
const std::string what() const throw () {
std::ostringstream msg;
msg << " *** Error: Dimension error: " << msg_
<< "\n";
return msg.str();
}
};
/**
* \class ShelxFormat
* \brief Error parsing SHELXL ins-file
*/
class ShelxFormat: public myException {
public:
ShelxFormat (const std::string text): myException (text) {}
~ShelxFormat() throw () {}
const std::string what() const throw () {
std::ostringstream msg;
msg << " *** Error: Unsupported Image format. File " << msg_
<< "\n";
return msg.str();
}
};
/**
* \class ShelxEoF
* \brief End of file (END or HKLF instruction)
*/
class ShelxEoF: public myException {
public:
ShelxEoF (const std::string text): myException (text) {}
~ShelxEoF() throw () {}
const std::string what() const throw () {
std::ostringstream msg;
msg << " *** Error: Unsupported Image format. File " << msg_
<< "\n";
return msg.str();
}
};
/**
* \class ImageFormat
* \brief Exception to be thrown for unsupported image formats.
*/
class Format: public myException {
public:
Format (const std::string text): myException (text) {}
~Format() throw () {}
const std::string what() const throw () {
std::ostringstream msg;
msg << " *** Error: Error in input format. " << msg_
<< "\n";
return msg.str();
}
};
/**
* \class Usage
* \brief Thrown when program comes to stage where it should not be
*/
class Usage: public myException {
public:
Usage (const std::string text): myException (text) {}
~Usage() throw () {}
const std::string what() const throw () {
std::ostringstream msg;
msg << " *** Error in Program Flow: " << msg_
<< "\n";
return msg.str();
}
};
}
#endif /* MYEXCEPTIONS_H */