1 /*
2  Copyright (C) 2008 Grame
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as published by
6  the Free Software Foundation; either version 2.1 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  GNU Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 
18 */
19 
20 #ifndef __JackException__
21 #define __JackException__
22 
23 #include "JackCompilerDeps.h"
24 
25 #include <stdexcept>
26 #include <iostream>
27 #include <string>
28 
29 namespace Jack
30 {
31 
32 #define	ThrowIf(inCondition, inException)                                               \
33 			if(inCondition)																\
34 			{																			\
35 				throw(inException);														\
36 			}
37 
38 
39 /*!
40 \brief Exception base class.
41 */
42 
43 class SERVER_EXPORT JackException : public std::runtime_error {
44 
45     public:
46 
JackException(const std::string & msg)47         JackException(const std::string& msg) : std::runtime_error(msg)
48         {}
JackException(char * msg)49         JackException(char* msg) : std::runtime_error(msg)
50         {}
JackException(const char * msg)51         JackException(const char* msg) : std::runtime_error(msg)
52         {}
53 
Message()54         std::string Message()
55         {
56             return what();
57         }
58 
59         void PrintMessage();
60 
61  };
62 
63 /*!
64  \brief Exception thrown by JackEngine in temporary mode.
65  */
66 
67 class SERVER_EXPORT JackTemporaryException : public JackException {
68 
69     public:
70 
JackTemporaryException(const std::string & msg)71         JackTemporaryException(const std::string& msg) : JackException(msg)
72         {}
JackTemporaryException(char * msg)73         JackTemporaryException(char* msg) : JackException(msg)
74         {}
JackTemporaryException(const char * msg)75         JackTemporaryException(const char* msg) : JackException(msg)
76         {}
JackTemporaryException()77         JackTemporaryException() : JackException("")
78         {}
79 };
80 
81 /*!
82  \brief
83  */
84 
85 class SERVER_EXPORT JackQuitException : public JackException {
86 
87     public:
88 
JackQuitException(const std::string & msg)89         JackQuitException(const std::string& msg) : JackException(msg)
90         {}
JackQuitException(char * msg)91         JackQuitException(char* msg) : JackException(msg)
92         {}
JackQuitException(const char * msg)93         JackQuitException(const char* msg) : JackException(msg)
94         {}
JackQuitException()95         JackQuitException() : JackException("")
96         {}
97 };
98 
99 /*!
100 \brief Exception possibly thrown by Net slaves.
101 */
102 
103 class SERVER_EXPORT JackNetException : public JackException {
104 
105     public:
106 
JackNetException(const std::string & msg)107         JackNetException(const std::string& msg) : JackException(msg)
108         {}
JackNetException(char * msg)109         JackNetException(char* msg) : JackException(msg)
110         {}
JackNetException(const char * msg)111         JackNetException(const char* msg) : JackException(msg)
112         {}
JackNetException()113         JackNetException() : JackException("")
114         {}
115 };
116 
117 }
118 
119 #endif
120