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