FreeRDP-WebConnect WebSockets gateway  1.0.0.167
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
btexception.hpp
1 /* vim: set et ts=4 sw=4 cindent:
2  *
3  * FreeRDP-WebConnect,
4  * A gateway for seamless access to your RDP-Sessions in any HTML5-compliant browser.
5  *
6  * Copyright 2012 Fritz Elfert <wsgate@fritz-elfert.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 #ifndef BTEXCEPTION_H
21 #define BTEXCEPTION_H
22 
23 #include <exception>
24 #include <string>
25 
30 namespace tracing {
31 
37  {
38  public:
40  dummy_tracer(int) { }
41 
46  std::string trace(int) const
47  {
48  return "Tracing disabled";
49  }
50  };
51 
52 #ifdef USE_BFD
53 
59  class bfd_tracer
60  {
61  public:
62 
67  bfd_tracer(int _maxframes);
68 
72  ~bfd_tracer();
73 
83  const std::string & trace(int skip) const;
84 
86  bfd_tracer(const bfd_tracer &);
87 
88  private:
90  int maxframes;
92  int frames;
94  void **tbuf;
96  bfd_tracer & operator = (const bfd_tracer &);
97 
98  };
99 #endif
100 #ifdef USE_DWARF
101 
107  {
108  public:
113  dwarf_tracer(int _maxframes);
114 
118  ~dwarf_tracer();
119 
129  const std::string & trace(int skip) const;
130 
132  dwarf_tracer(const dwarf_tracer &);
133 
136 
137  private:
138  int maxframes;
139  int frames;
140  void **tbuf;
141  };
142 #endif
143 
149  class exception : public std::exception
150  {
151  public:
155  exception() throw();
156 
157  virtual ~exception() throw();
158 
163  virtual const char* where() const throw();
164 
165  private:
166 #ifdef USE_BFD
167  bfd_tracer tracer;
168 #else
169 # ifdef USE_DWARF
170  dwarf_tracer tracer;
171 # else
172 # warning Neither libbfd nor libdwarf are available, so no backtracing enabled
173  dummy_tracer tracer;
174 # endif
175 #endif
176  };
177 
183  class runtime_error : public exception
184  {
185  public:
190  explicit runtime_error(const std::string& __arg)
191  : exception(), msg(__arg) { }
193  virtual ~runtime_error() throw() { }
198  virtual const char* what() const throw()
199  { return msg.c_str(); }
200 
201  private:
202  std::string msg;
203  };
204 
210  class logic_error : public exception
211  {
212  std::string _M_msg;
213 
214  public:
218  explicit logic_error(const std::string& __arg) : _M_msg(__arg) { }
220  virtual ~logic_error() throw() { }
225  virtual const char* what() const throw() { return _M_msg.c_str(); }
226  };
227 
231  class domain_error : public logic_error
232  {
233  public:
237  explicit domain_error(const std::string& __arg);
238  };
239 
242  {
243  public:
247  explicit invalid_argument(const std::string& __arg) : logic_error(__arg) { }
248  };
249 
252  class length_error : public logic_error
253  {
254  public:
258  explicit length_error(const std::string& __arg);
259  };
260 
263  class out_of_range : public logic_error
264  {
265  public:
269  explicit out_of_range(const std::string& __arg);
270  };
271 
272 
274  class range_error : public runtime_error
275  {
276  public:
280  explicit range_error(const std::string& __arg);
281  };
282 
285  {
286  public:
290  explicit overflow_error(const std::string& __arg);
291  };
292 
295  {
296  public:
300  explicit underflow_error(const std::string& __arg);
301  };
302 
303 }
304 
305 #endif