1 """ 2 websocket - WebSocket client library for Python 3 4 Copyright (C) 2010 Hiroki Ohtani(liris) 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public 8 License as published by the Free Software Foundation; either 9 version 2.1 of the License, or (at your option) any later version. 10 11 This library is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Lesser General Public License for more details. 15 16 You should have received a copy of the GNU Lesser General Public 17 License along with this library; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 Boston, MA 02110-1335 USA 20 21 """ 22 23 24 """ 25 define websocket exceptions 26 """ 27 28 29 class WebSocketException(Exception): 30 """ 31 websocket exception class. 32 """ 33 pass 34 35 36 class WebSocketProtocolException(WebSocketException): 37 """ 38 If the websocket protocol is invalid, this exception will be raised. 39 """ 40 pass 41 42 43 class WebSocketPayloadException(WebSocketException): 44 """ 45 If the websocket payload is invalid, this exception will be raised. 46 """ 47 pass 48 49 50 class WebSocketConnectionClosedException(WebSocketException): 51 """ 52 If remote host closed the connection or some network error happened, 53 this exception will be raised. 54 """ 55 pass 56 57 58 class WebSocketTimeoutException(WebSocketException): 59 """ 60 WebSocketTimeoutException will be raised at socket timeout during read/write data. 61 """ 62 pass 63 64 65 class WebSocketProxyException(WebSocketException): 66 """ 67 WebSocketProxyException will be raised when proxy error occurred. 68 """ 69 pass 70 71 72 class WebSocketBadStatusException(WebSocketException): 73 """ 74 WebSocketBadStatusException will be raised when we get bad handshake status code. 75 """ 76 77 def __init__(self, message, status_code): 78 super(WebSocketBadStatusException, self).__init__( 79 message % status_code) 80 self.status_code = status_code 81