jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
2.9KB

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