Audaspace  1.3.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(std::string message, std::string file, int line);
73 public:
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(std::string message, std::string file, int line);
124 
129  FileException(const FileException& exception);
130 
132 };
133 
140 {
141 public:
148  DeviceException(std::string message, std::string file, int line);
149 
154  DeviceException(const DeviceException& exception);
155 
157 };
158 
166 {
167 public:
174  StateException(std::string message, std::string file, int line);
175 
180  StateException(const StateException& exception);
181 
183 };
184 
StateException::StateException
StateException(const StateException &exception)
Copy constructor.
DeviceException
The DeviceException class is used for error cases in connection with devices, which usually happens w...
Definition: Exception.h:140
Exception::Exception
Exception(std::string message, std::string file, int line)
Creates a new Exception object.
FileException::FileException
FileException(std::string message, std::string file, int line)
Creates a new FileException object.
FileException
The FileException class is used for error cases in which files cannot be read or written due to unkno...
Definition: Exception.h:115
Exception::~Exception
virtual ~Exception() AUD_NOEXCEPT
Destroys the object.
StateException
The StateException class is used for error cases of sounds or readers with illegal states or requirem...
Definition: Exception.h:166
FileException::FileException
FileException(const FileException &exception)
Copy constructor.
DeviceException::DeviceException
DeviceException(std::string message, std::string file, int line)
Creates a new DeviceException object.
Exception::m_file
const std::string m_file
The source code file in which the exception was thrown.
Definition: Exception.h:55
Exception
The Exception class is the general exception base class.
Definition: Exception.h:49
Exception::Exception
Exception(const Exception &exception)
Copy constructor.
DeviceException::DeviceException
DeviceException(const DeviceException &exception)
Copy constructor.
StateException::StateException
StateException(std::string message, std::string file, int line)
Creates a new StateException object.
AUD_NAMESPACE_END
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition: Audaspace.h:119
Exception::m_line
const int m_line
The source code line from which the exception was thrown.
Definition: Exception.h:58
AUD_NAMESPACE_BEGIN
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition: Audaspace.h:116
AUD_API
#define AUD_API
Used for exporting symbols in the shared library.
Definition: Audaspace.h:93
AUD_NOEXCEPT
#define AUD_NOEXCEPT
Compatibility macro for noexcept.
Definition: Exception.h:26
Exception::m_message
const std::string m_message
A message describing the problem.
Definition: Exception.h:52
Audaspace.h
The main header file of the library defining the namespace and basic data types.