fix error message, update exception import

This commit is contained in:
Timothy Pogue 2022-10-10 23:30:43 -06:00
parent db8cf6c957
commit 5ada5eb540

View File

@ -1,10 +1,10 @@
import logging import logging
from typing import Any, Dict from typing import Any, Dict
import websockets
from fastapi import APIRouter, Depends, WebSocketDisconnect from fastapi import APIRouter, Depends, WebSocketDisconnect
from fastapi.websockets import WebSocket, WebSocketState from fastapi.websockets import WebSocket, WebSocketState
from pydantic import ValidationError from pydantic import ValidationError
from websockets.exceptions import WebSocketException
from freqtrade.enums import RPCMessageType, RPCRequestType from freqtrade.enums import RPCMessageType, RPCRequestType
from freqtrade.rpc.api_server.api_auth import validate_ws_token from freqtrade.rpc.api_server.api_auth import validate_ws_token
@ -115,10 +115,7 @@ async def message_endpoint(
# Process the request here # Process the request here
await _process_consumer_request(request, channel, rpc) await _process_consumer_request(request, channel, rpc)
except ( except (WebSocketDisconnect, WebSocketException):
WebSocketDisconnect,
websockets.exceptions.WebSocketException
):
# Handle client disconnects # Handle client disconnects
logger.info(f"Consumer disconnected - {channel}") logger.info(f"Consumer disconnected - {channel}")
except RuntimeError: except RuntimeError:
@ -126,7 +123,7 @@ async def message_endpoint(
# RuntimeError('Cannot call "send" once a closed message has been sent') # RuntimeError('Cannot call "send" once a closed message has been sent')
pass pass
except Exception as e: except Exception as e:
logger.info(f"Consumer connection failed - {channel}") logger.info(f"Consumer connection failed - {channel}: {e}")
logger.debug(e, exc_info=e) logger.debug(e, exc_info=e)
finally: finally:
await channel_manager.on_disconnect(ws) await channel_manager.on_disconnect(ws)