My Project
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Properties Macros
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 char const* what() const noexcept override;
50 
54  virtual std::exception_ptr self() const override;
55 };
56 
62 class UNITY_API LogicException : public Exception
63 {
64 public:
69  explicit LogicException(std::string const& reason);
72  LogicException& operator=(LogicException const&);
73  virtual ~LogicException() noexcept;
75 
79  virtual char const* what() const noexcept override;
80 
84  virtual std::exception_ptr self() const override;
85 };
86 
96 class UNITY_API ShutdownException : public Exception
97 {
98 public:
103  explicit ShutdownException(std::string const& reason);
106  ShutdownException& operator=(ShutdownException const&);
107  virtual ~ShutdownException() noexcept;
109 
113  virtual char const* what() const noexcept override;
114 
118  virtual std::exception_ptr self() const override;
119 };
120 
121 namespace internal
122 {
123 class FileExceptionImpl;
124 }
125 
130 class UNITY_API FileException : public Exception
131 {
132 public:
141  FileException(std::string const& reason, int err);
144  FileException& operator=(FileException const&);
145  virtual ~FileException() noexcept;
147 
151  virtual char const* what() const noexcept override;
152 
156  virtual std::exception_ptr self() const override;
157 
161  int error() const noexcept;
162 
163 private:
164  std::shared_ptr<internal::FileExceptionImpl> p_;
165 };
166 
167 namespace internal
168 {
169 class SyscallExceptionImpl;
170 }
171 
176 class UNITY_API SyscallException : public Exception
177 {
178 public:
187  SyscallException(std::string const& reason, int err);
190  SyscallException& operator=(SyscallException const&);
191  virtual ~SyscallException() noexcept;
193 
197  virtual char const* what() const noexcept override;
198 
202  virtual std::exception_ptr self() const override;
203 
207  int error() const noexcept;
208 
209 private:
210  //std::shared_ptr<internal::SyscallExceptionImpl> p_;
211 };
212 
217 class UNITY_API ResourceException : public Exception
218 {
219 public:
224  explicit ResourceException(std::string const& reason);
227  ResourceException& operator=(ResourceException const&);
228  virtual ~ResourceException() noexcept;
230 
234  virtual char const* what() const noexcept override;
235 
239  virtual std::exception_ptr self() const override;
240 };
241 
242 } // namespace unity
243 
244 #endif