diff options
Diffstat (limited to 'util/fbcompose/Exceptions.hh')
-rw-r--r-- | util/fbcompose/Exceptions.hh | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/util/fbcompose/Exceptions.hh b/util/fbcompose/Exceptions.hh new file mode 100644 index 0000000..7c5b042 --- /dev/null +++ b/util/fbcompose/Exceptions.hh | |||
@@ -0,0 +1,141 @@ | |||
1 | /** Exceptions.hh file for the fluxbox compositor. */ | ||
2 | |||
3 | // Copyright (c) 2011 Gediminas Liktaras (gliktaras at gmail dot com) | ||
4 | // | ||
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
6 | // of this software and associated documentation files (the "Software"), to deal | ||
7 | // in the Software without restriction, including without limitation the rights | ||
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
9 | // copies of the Software, and to permit persons to whom the Software is | ||
10 | // furnished to do so, subject to the following conditions: | ||
11 | // | ||
12 | // The above copyright notice and this permission notice shall be included in | ||
13 | // all copies or substantial portions of the Software. | ||
14 | // | ||
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
21 | // THE SOFTWARE. | ||
22 | |||
23 | |||
24 | #ifndef FBCOMPOSITOR_EXCEPTIONS_HH | ||
25 | #define FBCOMPOSITOR_EXCEPTIONS_HH | ||
26 | |||
27 | #include "FbTk/FbString.hh" | ||
28 | |||
29 | #include <exception> | ||
30 | |||
31 | |||
32 | namespace FbCompositor { | ||
33 | |||
34 | //--- BASE EXCEPTION ------------------------------------------------------- | ||
35 | |||
36 | /** | ||
37 | * Base class for all exceptions in the project's namespace. | ||
38 | */ | ||
39 | class CompositorException : public std::exception { | ||
40 | public: | ||
41 | /** The constructor. */ | ||
42 | CompositorException(FbTk::FbString error_message) : | ||
43 | m_error_message(error_message) {} | ||
44 | |||
45 | /** Destructor. */ | ||
46 | virtual ~CompositorException() throw() {} | ||
47 | |||
48 | /** \returns The main error message. */ | ||
49 | virtual const char *what() const throw() { return m_error_message.c_str(); } | ||
50 | |||
51 | private: | ||
52 | /** The exception's main message. */ | ||
53 | FbTk::FbString m_error_message; | ||
54 | }; | ||
55 | |||
56 | |||
57 | //--- DERIVED EXCEPTIONS --------------------------------------------------- | ||
58 | |||
59 | /** | ||
60 | * This exception is thrown whenever an error condition is encountered in | ||
61 | * initialization of compositor's components. | ||
62 | */ | ||
63 | class InitException : public CompositorException { | ||
64 | public: | ||
65 | /** Public constructor. */ | ||
66 | InitException(FbTk::FbString error_message) : | ||
67 | CompositorException(error_message) {} | ||
68 | }; | ||
69 | |||
70 | /** | ||
71 | * This exception is thrown whenever an error condition is encountered when | ||
72 | * the compositor has been initialized and is running. | ||
73 | */ | ||
74 | class RuntimeException : public CompositorException { | ||
75 | public: | ||
76 | /** Public constructor. */ | ||
77 | RuntimeException(FbTk::FbString error_message) : | ||
78 | CompositorException(error_message) {} | ||
79 | }; | ||
80 | |||
81 | |||
82 | //--- MORE CONCRETE EXCEPTION TYPES ---------------------------------------- | ||
83 | |||
84 | /** | ||
85 | * This exception is thrown whenever an error condition is encountered | ||
86 | * when processing the configuration data. | ||
87 | */ | ||
88 | class ConfigException : public InitException { | ||
89 | public: | ||
90 | /** Public constructor. */ | ||
91 | ConfigException(FbTk::FbString error_message) : | ||
92 | InitException(error_message) {} | ||
93 | }; | ||
94 | |||
95 | /** | ||
96 | * This exception is thrown whenever an error condition is encountered | ||
97 | * while initializing (loading, creating instances etc) plugins. | ||
98 | */ | ||
99 | class PluginException : public InitException { | ||
100 | public: | ||
101 | /** Public constructor. */ | ||
102 | PluginException(FbTk::FbString error_message) : | ||
103 | InitException(error_message) {} | ||
104 | }; | ||
105 | |||
106 | |||
107 | /** | ||
108 | * This exception is thrown whenever an index-related error condition | ||
109 | * occurs. | ||
110 | */ | ||
111 | class IndexException : public RuntimeException { | ||
112 | public: | ||
113 | /** Public constructor. */ | ||
114 | IndexException(FbTk::FbString error_message) : | ||
115 | RuntimeException(error_message) {} | ||
116 | }; | ||
117 | |||
118 | /** | ||
119 | * This exception is thrown whenever an error occurs while attempting to | ||
120 | * obtain current system time. | ||
121 | */ | ||
122 | class TimeException : public RuntimeException { | ||
123 | public: | ||
124 | /** Public constructor. */ | ||
125 | TimeException(FbTk::FbString error_message) : | ||
126 | RuntimeException(error_message) {} | ||
127 | }; | ||
128 | |||
129 | /** | ||
130 | * This exception is thrown whenever an error occurs while manipulating the | ||
131 | * windows in response to X's events. | ||
132 | */ | ||
133 | class WindowException : public RuntimeException { | ||
134 | public: | ||
135 | /** Public constructor. */ | ||
136 | WindowException(FbTk::FbString error_message) : | ||
137 | RuntimeException(error_message) {} | ||
138 | }; | ||
139 | } | ||
140 | |||
141 | #endif // FBCOMPOSITOR_EXCEPTIONS_HH | ||