-
Notifications
You must be signed in to change notification settings - Fork 3
/
exception_handling.h
104 lines (90 loc) · 2.53 KB
/
exception_handling.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
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
//
// Created by Robert Stolz on 6/28/17.
//
#ifndef RLOOPER2_EXCEPTION_HANDLING_H
#define RLOOPER2_EXCEPTION_HANDLING_H
#include <exception>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
class ModelException1: public exception{
virtual const char* what() const throw()
{
return "The compute_structures function has been given a non-empty vector of structures.";
}
};
class DefaultConstructorException : public exception{
private:
string triggering_object;
string message = "A prohibited default constructor has been used for object: ";
public:
DefaultConstructorException(string object) {
triggering_object = object;
};
virtual const char* what() const throw()
{
const string return_message = message + triggering_object;
return return_message.c_str();
}
};
class InvalidSequenceDataException : public exception{
private:
string triggering_char;
string message = "The following character in the input sequence is unrecognized: ";
public:
InvalidSequenceDataException(char c){
stringstream ss;
ss << c;
ss >> triggering_char;
};
virtual const char* what() const throw()
{
return (message + triggering_char).c_str();
}
};
class EmptyGeneException: public exception{
virtual const char* what() const throw()
{
return "There is an unrecognized or out of place charicter in the input sequence.";
}
};
class UnexpectedEOFException: public exception{
virtual const char* what() const throw()
{
return "End of file reached unexpectedly.";
}
};
class UnexpectedClosedFileException : public exception{
private:
string triggering_function;
string message = "The following function has recieved a closed filestream: ";
public:
UnexpectedClosedFileException(string c){
stringstream ss;
ss << c;
ss >> triggering_function;
};
virtual const char* what() const throw()
{
return (message + triggering_function).c_str();
}
};
class WindowerException: public exception{
virtual const char* what() const throw()
{
return "A fatal error has occurred in the Windower class.";
}
};
class SimulationException: public exception {
private:
string description_message;
string message = "The simulation has thrown an unhandled excpetion: ";
public:
SimulationException(string c) {
stringstream ss;
ss << c;
ss >> description_message;
}
};
#endif //RLOOPER2_EXCEPTION_HANDLING_H