My Project
Loading...
Searching...
No Matches
UnityExceptions.h
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Michi Henning <michi.henning@canonical.com>
17 */
18
19#ifndef UNITY_EXCEPTIONS_H
20#define UNITY_EXCEPTIONS_H
21
22#include <unity/Exception.h>
23
24namespace unity
25{
26
31
32class UNITY_API InvalidArgumentException : public Exception
33{
34public:
39 explicit InvalidArgumentException(std::string const& reason);
43 virtual ~InvalidArgumentException() noexcept;
45
49 virtual std::exception_ptr self() const override;
50};
51
56
57class UNITY_API LogicException : public Exception
58{
59public:
64 explicit LogicException(std::string const& reason);
67 LogicException& operator=(LogicException const&);
68 virtual ~LogicException() noexcept;
70
74 virtual std::exception_ptr self() const override;
75};
76
85
86class UNITY_API ShutdownException : public Exception
87{
88public:
93 explicit ShutdownException(std::string const& reason);
96 ShutdownException& operator=(ShutdownException const&);
97 virtual ~ShutdownException() noexcept;
99
103 virtual std::exception_ptr self() const override;
104};
105
106
110
111class UNITY_API FileException : public Exception
112{
113public:
122 FileException(std::string const& reason, int err);
125 FileException& operator=(FileException const&);
126 virtual ~FileException() noexcept;
128
132 virtual std::exception_ptr self() const override;
133
137 int error() const noexcept;
138
139private:
140 int err_;
141};
142
146
147class UNITY_API SyscallException : public Exception
148{
149public:
158 SyscallException(std::string const& reason, int err);
161 SyscallException& operator=(SyscallException const&);
162 virtual ~SyscallException() noexcept;
164
168 virtual std::exception_ptr self() const override;
169
173 int error() const noexcept;
174
175private:
176 int err_;
177};
178
182
183class UNITY_API ResourceException : public Exception
184{
185public:
190 explicit ResourceException(std::string const& reason);
193 ResourceException& operator=(ResourceException const&);
194 virtual ~ResourceException() noexcept;
196
200 virtual std::exception_ptr self() const override;
201};
202
203} // namespace unity
204
205#endif
Exception(std::string const &name, std::string const &reason)
Constructs an exception instance.
Definition Exception.cpp:165
std::string reason() const
Returns the reason set by the derived class's constructor (empty string if none).
Definition Exception.cpp:224
virtual std::exception_ptr self() const override
Returns a std::exception_ptr to this.
Definition UnityExceptions.cpp:109
FileException(std::string const &reason, int err)
Constructs the exception.
Definition UnityExceptions.cpp:87
int error() const noexcept
Definition UnityExceptions.cpp:104
InvalidArgumentException(std::string const &reason)
Constructs the exception.
Definition UnityExceptions.cpp:26
virtual std::exception_ptr self() const override
Returns a std::exception_ptr to this.
Definition UnityExceptions.cpp:42
virtual std::exception_ptr self() const override
Returns a std::exception_ptr to this.
Definition UnityExceptions.cpp:62
LogicException(std::string const &reason)
Constructs the exception.
Definition UnityExceptions.cpp:47
ResourceException(std::string const &reason)
Constructs the exception.
Definition UnityExceptions.cpp:140
virtual std::exception_ptr self() const override
Returns a std::exception_ptr to this.
Definition UnityExceptions.cpp:155
ShutdownException(std::string const &reason)
Constructs the exception.
Definition UnityExceptions.cpp:67
virtual std::exception_ptr self() const override
Returns a std::exception_ptr to this.
Definition UnityExceptions.cpp:82
SyscallException(std::string const &reason, int err)
Constructs the exception.
Definition UnityExceptions.cpp:114
int error() const noexcept
Definition UnityExceptions.cpp:130
virtual std::exception_ptr self() const override
Returns a std::exception_ptr to this.
Definition UnityExceptions.cpp:135
Top-level namespace for all things Unity-related.
Definition Version.h:38