My Project
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 
24 namespace unity
25 {
26 
32 class UNITY_API InvalidArgumentException : public Exception
33 {
34 public:
39  explicit InvalidArgumentException(std::string const& reason);
43  virtual ~InvalidArgumentException() noexcept;
45 
49  virtual std::exception_ptr self() const override;
50 };
51 
57 class UNITY_API LogicException : public Exception
58 {
59 public:
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 
86 class UNITY_API ShutdownException : public Exception
87 {
88 public:
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 
111 class UNITY_API FileException : public Exception
112 {
113 public:
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 
139 private:
140  int err_;
141 };
142 
147 class UNITY_API SyscallException : public Exception
148 {
149 public:
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 
175 private:
176  int err_;
177 };
178 
183 class UNITY_API ResourceException : public Exception
184 {
185 public:
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
Abstract base class for all Unity exceptions.
Definition: Exception.h:103
Exception for miscellaneous errors, such as failure of a third-party library or hitting resource limi...
Definition: UnityExceptions.h:183
Exception to indicate file I/O errors, such as failure to open or write to a file.
Definition: UnityExceptions.h:111
Exception to indicate a logic error, such as driving the API incorrectly, such as calling methods in ...
Definition: UnityExceptions.h:57
Top-level namespace for all things Unity-related.
Definition: Version.h:37
Exception to indicate that an invalid argument was passed to a function, such as passing nullptr when...
Definition: UnityExceptions.h:32
Exception to indicate errors during shutdown.
Definition: UnityExceptions.h:86
Exception to indicate system or library call errors that set errno.
Definition: UnityExceptions.h:147