Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
croflexception.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef CROFLEXCEPTION_H
6 #define CROFLEXCEPTION_H
7 
8 #include <assert.h>
9 
10 #include <set>
11 #include <string>
12 #include <iostream>
13 
14 #include <string.h>
15 #include <errno.h>
16 #include <stdio.h>
17 #include <strings.h>
18 #include <stdarg.h>
19 #include <stdexcept>
20 
21 namespace rofl
22 {
23 
24 /*
25  * base class for entire error class hierarchy in rofl
26  */
27 class RoflException : public std::runtime_error {
28 public:
29  RoflException(const std::string& __arg = std::string("")) :
30  std::runtime_error(__arg) {};
31  virtual ~RoflException() throw() {};
32 public:
33  friend std::ostream&
34  operator<< (std::ostream& os, const RoflException& e) {
35  os << "<RoflException: " << e.what() << " >";
36  return os;
37  };
38 };
39 
40 class eSysCall : public RoflException {
41 public:
42  eSysCall(std::string const& syscall = std::string("unknown")) :
43  RoflException("syscall: "+syscall+" "+std::string(__FILE__)+std::string(":")+std::string(__func__)),
44  n_err(errno), s_err(strerror(errno)) {};
45  virtual ~eSysCall() throw() {};
46 public:
47  friend std::ostream& operator<< (std::ostream& os, eSysCall const& e) {
48  os << "<eSysCall syscall:" << e.what() << " errno: " << e.n_err << " (" << e.s_err << ") >";
49  return os;
50  };
51 
52 private:
53  int n_err;
54  std::string s_err;
55 };
56 
58 public:
60  const std::string& __arg = std::string("eNotImplemented")) :
61  RoflException(__arg) {};
62  virtual ~eNotImplemented() throw() {};
63 };
64 
65 class eInval : public RoflException {
66 public:
67  eInval(
68  const std::string& __arg = std::string("eInval")) :
69  RoflException(__arg) {};
70  virtual ~eInval() throw() {};
71 };
72 
73 class eBadVersion : public RoflException {
74 public:
76  const std::string& __arg = std::string("eBadVersion")) :
77  RoflException(__arg) {
78 #ifndef NDEBUG
79  std::cerr << "BAD-WOLF" << std::endl;
80 // assert(0 == 1);
81 #endif
82  };
83 };
84 
85 class eBadSyntax : public RoflException {
86 public:
87  eBadSyntax(
88  const std::string& __arg = std::string("eBadSyntax")) :
89  RoflException(__arg) {};
90 };
91 
93 public:
95  const std::string& __arg = std::string("eBadSyntaxTooShort")) :
96  eBadSyntax(__arg) {};
97 };
98 
99 }; // end of namespace
100 
101 #endif
102 
103 
104 
Definition: croflexception.h:73
Definition: croflexception.h:57
Definition: croflexception.h:65
Definition: croflexception.h:40
Definition: croflexception.h:85
Definition: croflexception.h:92
Definition: croflexception.h:27