Skip to content
Permalink
Browse files
修改异常的处理方式,填充reason和message属性
  • Loading branch information
JoeCao committed Mar 7, 2016
1 parent 8b86353 commit 6c6a74831f730659239f83a19ced6b6d9ae6fd7a
Showing 1 changed file with 11 additions and 6 deletions.
@@ -3,10 +3,9 @@
from urllib2 import HTTPError

from pyjsonrpc import HttpClient, JsonRpcError
from dubbo_client.registry import Registry

from dubbo_client.rpcerror import NoProvider, ConnectionFail, dubbo_client_errors, InternalError

from dubbo_client.registry import Registry
from dubbo_client.rpcerror import NoProvider, ConnectionFail, dubbo_client_errors, InternalError, DubboClientError

__author__ = 'caozupeng'

@@ -46,9 +45,15 @@ def call(self, method, *args, **kwargs):
except HTTPError, e:
raise ConnectionFail(None, e.filename)
except JsonRpcError, error:
raise dubbo_client_errors.get(error.code, None)
if error.code in dubbo_client_errors:
raise dubbo_client_errors[error.code](message=error.message, data=error.data)
else:
raise DubboClientError(code=error.code, message=error.message, data=error.data)
except Exception, ue:
raise InternalError(ue.message, None)
if hasattr(ue, 'reason'):
raise InternalError(ue.message, ue.reason)
else:
raise InternalError(ue.message, None)

def __call__(self, method, *args, **kwargs):
"""
@@ -64,4 +69,4 @@ def __getattr__(self, method):


if __name__ == '__main__':
pass
pass

0 comments on commit 6c6a748

Please sign in to comment.