Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
 ryu/app/ofctl/exception.py | 4 ++++
 ryu/app/ofctl/service.py   | 9 ++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/ryu/app/ofctl/exception.py b/ryu/app/ofctl/exception.py
index 90113ae..c49f33f 100644
--- a/ryu/app/ofctl/exception.py
+++ b/ryu/app/ofctl/exception.py
@@ -27,3 +27,7 @@ class _ExceptionBase(exception.RyuException):
 
 class UnexpectedMultiReply(_ExceptionBase):
     message = 'Unexpected Multi replies %(result)s'
+
+
+class OFError(_ExceptionBase):
+    message = 'OpenFlow errors %(result)s'
diff --git a/ryu/app/ofctl/service.py b/ryu/app/ofctl/service.py
index cb6ba19..64ed789 100644
--- a/ryu/app/ofctl/service.py
+++ b/ryu/app/ofctl/service.py
@@ -61,6 +61,11 @@ class OfctlService(app_manager.RyuApp):
             self.unobserve_event(ev_cls)
             self.logger.debug('ofctl: stop observing %s' % (ev_cls,))
 
+    @staticmethod
+    def _is_error(msg):
+        return (ofp_event.ofp_msg_to_ev_cls(type(msg)) ==
+                ofp_event.EventOFPErrorMsg)
+
     @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
     def _switch_features_handler(self, ev):
         datapath = ev.msg.datapath
@@ -141,7 +146,9 @@ class OfctlService(app_manager.RyuApp):
         req = si.xids.pop(xid)
         if not req.reply_cls is None:
             self._unobserve_msg(req.reply_cls)
-        if req.reply_multi:
+        if any(self._is_error(r) for r in result):
+            rep = event.Reply(exception=exception.OFError(result=result))
+        elif req.reply_multi:
             rep = event.Reply(result=result)
         elif len(result) == 0:
             rep = event.Reply()
-- 
1.8.3.1


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to