-
Notifications
You must be signed in to change notification settings - Fork 0
/
Exceptions.h
executable file
·59 lines (48 loc) · 1.59 KB
/
Exceptions.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
/*
* Exceptions.h
*
* Created on: Sep 18, 2016
* Author: kempe
*/
/* This file contains custom-defined exceptions thrown to signal errors
or problems in various parts of the code.
All of them have a constructor with a string, and the string can
be retrieved using the getMessage() function (not what()).
The specific strings that are used to signal particular errors are
discussed where they are thrown.
*/
#ifndef EXCEPTIONS_H_
#define EXCEPTIONS_H_
#include <exception>
#include <stdexcept>
#include <string>
/* This exception is thrown when the config file is parsed and one or more
of the expected parameters are missing */
class ConfigParameterException : public std::exception {
public:
ConfigParameterException (std::string message) { _message = message; }
~ConfigParameterException () throw () {}
std::string getMessage () const { return _message; }
private:
std::string _message;
};
/* This exception is thrown when there are problems opening data files,
or when data files have format errors. */
class FileException : public std::exception {
public:
FileException (std::string message) { _message = message; }
~FileException () throw () {}
std::string getMessage () const { return _message; }
private:
std::string _message;
};
/* This exception is thrown when the player tried to make an invalid move. */
class MoveException : public std::exception {
public:
MoveException (std::string message) { _message = message; }
~MoveException () throw () {}
std::string getMessage () const { return _message; }
private:
std::string _message;
};
#endif /* EXCEPTIONS_H_ */