Audaspace  1.6.0
A high level audio library.
Exception.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright 2009-2016 Jörg Müller
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 #pragma once
18 
23 #ifdef _MSC_VER
24 #define AUD_NOEXCEPT
25 #else
26 #define AUD_NOEXCEPT noexcept
27 #endif
28 
35 #include "Audaspace.h"
36 
37 #include <exception>
38 #include <string>
39 
41 #define AUD_THROW(exception, message) { throw exception(message, __FILE__, __LINE__); }
42 
44 
48 class AUD_API Exception : public std::exception
49 {
50 protected:
52  const std::string m_message;
53 
55  const std::string m_file;
56 
58  const int m_line;
59 
64  Exception(const Exception& exception);
65 
72  Exception(const std::string &message, const std::string &file, int line);
73 public:
77  virtual ~Exception() AUD_NOEXCEPT;
78 
83  virtual const char* what() const AUD_NOEXCEPT;
84 
89  virtual std::string getDebugMessage() const;
90 
95  const std::string& getMessage() const;
96 
101  const std::string& getFile() const;
102 
107  int getLine() const;
108 };
109 
115 {
116 public:
123  FileException(const std::string &message, const std::string &file, int line);
124 
129  FileException(const FileException& exception);
130 
132 };
133 
140 {
141 public:
148  DeviceException(const std::string &message, const std::string &file, int line);
149 
154  DeviceException(const DeviceException& exception);
155 
157 };
158 
166 {
167 public:
174  StateException(const std::string &message, const std::string &file, int line);
175 
180  StateException(const StateException& exception);
181 
183 };
184 
const std::string m_message
A message describing the problem.
Definition: Exception.h:52
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition: Audaspace.h:116
#define AUD_NOEXCEPT
Compatibility macro for noexcept.
Definition: Exception.h:26
The DeviceException class is used for error cases in connection with devices, which usually happens w...
Definition: Exception.h:139
#define AUD_API
Used for exporting symbols in the shared library.
Definition: Audaspace.h:93
The FileException class is used for error cases in which files cannot be read or written due to unkno...
Definition: Exception.h:114
const int m_line
The source code line from which the exception was thrown.
Definition: Exception.h:58
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition: Audaspace.h:119
The Exception class is the general exception base class.
Definition: Exception.h:48
const std::string m_file
The source code file in which the exception was thrown.
Definition: Exception.h:55
The main header file of the library defining the namespace and basic data types.
The StateException class is used for error cases of sounds or readers with illegal states or requirem...
Definition: Exception.h:165