Permalink
Browse files

Catch socket errors when executing dashi operations

Raise these errors as CeiClientError to print only a simple error
string.
  • Loading branch information...
1 parent 8c8ba78 commit d6c3c97dc214a023847050409669e8a2659ef697 @priteau priteau committed Oct 9, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 ceiclient/connection.py
View
@@ -1,3 +1,4 @@
+import socket
import sys
import traceback
@@ -33,10 +34,16 @@ def __init__(self, broker, username, password, exchange=None, timeout=None, port
self.amqp_port), self.amqp_exchange, ssl=ssl)
def call(self, service, operation, **kwargs):
- return self.dashi_connection.call(service, operation, self.timeout, **kwargs)
+ try:
+ return self.dashi_connection.call(service, operation, self.timeout, **kwargs)
+ except socket.error as e:
+ raise CeiClientError(e)
def fire(self, service, operation, **kwargs):
- return self.dashi_connection.fire(service, operation, **kwargs)
+ try:
+ return self.dashi_connection.fire(service, operation, **kwargs)
+ except socket.error as e:
+ raise CeiClientError(e)
def disconnect(self):
self.dashi_connection.disconnect()

0 comments on commit d6c3c97

Please sign in to comment.