Unity Scopes API
ScopeExceptions.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 #pragma once
20 
21 #include <unity/Exception.h>
22 
23 namespace unity
24 {
25 
26 namespace scopes
27 {
28 
33 class MiddlewareException : public virtual unity::Exception
34 {
35 public:
40  explicit MiddlewareException(std::string const& reason);
41 
45  //{@
47  MiddlewareException& operator=(MiddlewareException const&);
49 
51  virtual ~MiddlewareException();
53 
58  virtual std::exception_ptr self() const override;
59 };
60 
67 {
68 public:
74  explicit ObjectNotExistException(std::string const& reason, std::string const& id);
75 
79  //{@
83 
85  virtual ~ObjectNotExistException();
87 
92  virtual std::exception_ptr self() const override;
93 
98  virtual std::string id() const;
99 
100 private:
101  std::string id_;
102 };
103 
108 class TimeoutException : public virtual MiddlewareException
109 {
110 public:
115  explicit TimeoutException(std::string const& reason);
116 
120  //{@
122  TimeoutException& operator=(TimeoutException const&);
124 
126  virtual ~TimeoutException();
128 
133  virtual std::exception_ptr self() const override;
134 };
135 
140 class ConfigException : public virtual unity::Exception
141 {
142 public:
147  explicit ConfigException(std::string const& reason);
148 
152  //{@
154  ConfigException& operator=(ConfigException const&);
156 
158  virtual ~ConfigException();
160 
165  virtual std::exception_ptr self() const override;
166 };
167 
172 class NotFoundException : public virtual unity::Exception
173 {
174 public:
180  explicit NotFoundException(std::string const& reason, std::string const& name);
181 
185  //{@
187  NotFoundException& operator=(NotFoundException const&);
189 
191  virtual ~NotFoundException();
193 
198  virtual std::exception_ptr self() const override;
199 
204  virtual std::string name() const;
205 
206 private:
207  std::string name_;
208 };
209 
210 } // namespace scopes
211 
212 } // namespace unity
virtual std::string id() const
Returns the identity of the non-existent object.
Definition: ScopeExceptions.cpp:75
NotFoundException(std::string const &reason, std::string const &name)
Constructs the exception.
Definition: ScopeExceptions.cpp:125
Exception to indicate that something went wrong with the middleware layer.
Definition: ScopeExceptions.h:33
virtual std::string name() const
Returns the name that was passed to the constructor.
Definition: ScopeExceptions.cpp:148
Exception to indicate that something went wrong with the contents of configuration files...
Definition: ScopeExceptions.h:140
TimeoutException(std::string const &reason)
Constructs the exception.
Definition: ScopeExceptions.cpp:80
Exception to indicate that an object wasn't found by a lookup function.
Definition: ScopeExceptions.h:172
Top-level namespace for all things Unity-related.
Definition: Version.h:49
MiddlewareException(std::string const &reason)
Constructs the exception.
Definition: ScopeExceptions.cpp:29
ObjectNotExistException(std::string const &reason, std::string const &id)
Constructs the exception.
Definition: ScopeExceptions.cpp:50
Exception to indicate that a twoway request timed out.
Definition: ScopeExceptions.h:108
Exception to indicate that a (twoway) request was sent to an object with an unknown identity...
Definition: ScopeExceptions.h:66
ConfigException(std::string const &reason)
Constructs the exception.
Definition: ScopeExceptions.cpp:102