Index: third_party/grpc/src/python/grpcio/grpc/framework/face/exceptions.py |
diff --git a/third_party/WebKit/LayoutTests/http/tests/websocket/close-on-unload_wsh.py b/third_party/grpc/src/python/grpcio/grpc/framework/face/exceptions.py |
similarity index 57% |
copy from third_party/WebKit/LayoutTests/http/tests/websocket/close-on-unload_wsh.py |
copy to third_party/grpc/src/python/grpcio/grpc/framework/face/exceptions.py |
index e23d40fecab973a70de107fc956ceeb5b459dc8c..f112df70bc694ba0aed9e6f22067d086366a2d8d 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/websocket/close-on-unload_wsh.py |
+++ b/third_party/grpc/src/python/grpcio/grpc/framework/face/exceptions.py |
@@ -1,4 +1,4 @@ |
-# Copyright 2009, Google Inc. |
+# Copyright 2015, Google Inc. |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
@@ -27,42 +27,51 @@ |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-import cgi |
-import json |
-from mod_pywebsocket import msgutil |
- |
- |
-connections = {} |
- |
- |
-def web_socket_do_extra_handshake(request): |
- pass # Always accept. |
- |
- |
-def web_socket_transfer_data(request): |
- global connections |
- r = request.ws_resource.split('?', 1) |
- if len(r) == 1: |
- return |
- param = cgi.parse_qs(r[1]) |
- if 'p' not in param: |
- return |
- page_group = param['p'][0] |
- if page_group in connections: |
- connections[page_group].add(request) |
- else: |
- connections[page_group] = set([request]) |
- message = None |
- dataToBroadcast = {} |
- try: |
- message = msgutil.receive_message(request) |
- # notify to client that message is received by server. |
- msgutil.send_message(request, message) |
- msgutil.receive_message(request) |
- dataToBroadcast['message'] = message |
- dataToBroadcast['closeCode'] = str(request.ws_close_code) |
- finally: |
- # request is closed. notify this dataToBroadcast to other WebSockets. |
- connections[page_group].remove(request) |
- for ws in connections[page_group]: |
- msgutil.send_message(ws, json.dumps(dataToBroadcast)) |
+"""Exceptions used in the Face layer of RPC Framework.""" |
+ |
+import abc |
+ |
+ |
+class NoSuchMethodError(Exception): |
+ """Raised by customer code to indicate an unrecognized RPC method name. |
+ |
+ Attributes: |
+ name: The unrecognized name. |
+ """ |
+ |
+ def __init__(self, name): |
+ """Constructor. |
+ |
+ Args: |
+ name: The unrecognized RPC method name. |
+ """ |
+ super(NoSuchMethodError, self).__init__() |
+ self.name = name |
+ |
+ |
+class RpcError(Exception): |
+ """Common super type for all exceptions raised by the Face layer. |
+ |
+ Only RPC Framework should instantiate and raise these exceptions. |
+ """ |
+ __metaclass__ = abc.ABCMeta |
+ |
+ |
+class CancellationError(RpcError): |
+ """Indicates that an RPC has been cancelled.""" |
+ |
+ |
+class ExpirationError(RpcError): |
+ """Indicates that an RPC has expired ("timed out").""" |
+ |
+ |
+class NetworkError(RpcError): |
+ """Indicates that some error occurred on the network.""" |
+ |
+ |
+class ServicedError(RpcError): |
+ """Indicates that the Serviced failed in the course of an RPC.""" |
+ |
+ |
+class ServicerError(RpcError): |
+ """Indicates that the Servicer failed in the course of servicing an RPC.""" |