Jack2 1.9.8

JackException.h

00001 /*
00002 Copyright (C) 2008 Grame
00003 
00004 This program is free software; you can redistribute it and/or modify
00005 it under the terms of the GNU General Public License as published by
00006 the Free Software Foundation; either version 2 of the License, or
00007 (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 
00018 */
00019 
00020 #ifndef __JackException__
00021 #define __JackException__
00022 
00023 #include <stdexcept>
00024 #include <iostream>
00025 #include <string>
00026 #include "JackError.h"
00027 
00028 namespace Jack
00029 {
00030 
00031 #define ThrowIf(inCondition, inException)                                               \
00032                         if(inCondition)                                                                                                                         \
00033                         {                                                                                                                                                       \
00034                                 throw(inException);                                                                                                             \
00035                         }
00036 
00037 
00042 class SERVER_EXPORT JackException : public std::runtime_error {
00043 
00044     public:
00045 
00046         JackException(const std::string& msg) : std::runtime_error(msg)
00047         {}
00048         JackException(char* msg) : std::runtime_error(msg)
00049         {}
00050         JackException(const char* msg) : std::runtime_error(msg)
00051         {}
00052 
00053         std::string Message()
00054         {
00055             return what();
00056         }
00057 
00058         void PrintMessage()
00059         {
00060             std::string str = what();
00061             if (str != "") {
00062                 jack_info(str.c_str());
00063             }
00064         }
00065 };
00066 
00071 class SERVER_EXPORT JackTemporaryException : public JackException {
00072 
00073     public:
00074 
00075         JackTemporaryException(const std::string& msg) : JackException(msg)
00076         {}
00077         JackTemporaryException(char* msg) : JackException(msg)
00078         {}
00079         JackTemporaryException(const char* msg) : JackException(msg)
00080         {}
00081         JackTemporaryException() : JackException("")
00082         {}
00083 };
00084 
00089 class SERVER_EXPORT JackQuitException : public JackException {
00090 
00091     public:
00092 
00093         JackQuitException(const std::string& msg) : JackException(msg)
00094         {}
00095         JackQuitException(char* msg) : JackException(msg)
00096         {}
00097         JackQuitException(const char* msg) : JackException(msg)
00098         {}
00099         JackQuitException() : JackException("")
00100         {}
00101 };
00102 
00107 class SERVER_EXPORT JackNetException : public JackException {
00108 
00109     public:
00110 
00111         JackNetException(const std::string& msg) : JackException(msg)
00112         {}
00113         JackNetException(char* msg) : JackException(msg)
00114         {}
00115         JackNetException(const char* msg) : JackException(msg)
00116         {}
00117         JackNetException() : JackException("")
00118         {}
00119 };
00120 
00121 }
00122 
00123 #endif