File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 4444import ssl
4545import uuid
4646import warnings
47+ import re
4748from collections import deque
4849from struct import unpack
4950
@@ -963,13 +964,21 @@ def send_startup(totp_value=None):
963964 self .backend_key = message .key
964965 elif isinstance (message , messages .ErrorResponse ):
965966 error_msg = message .error_message ()
966- if "Invalid TOTP" in error_msg :
967+
968+ # Extract only the "Message: ..." part
969+ match = re .search (r'Message: (.+?)(?:, Sqlstate|$)' , error_msg , re .DOTALL )
970+ short_msg = match .group (1 ).strip () if match else error_msg .strip ()
971+
972+ if "Invalid TOTP" in short_msg :
973+ print ("❌ Authentication failed: Invalid TOTP token." )
967974 self ._logger .error ("❌ Authentication failed: Invalid TOTP token." )
968975 self .close_socket ()
969976 raise errors .ConnectionError ("Authentication failed: Invalid TOTP token." )
977+
970978 # Generic error fallback
971- self ._logger .error (error_msg )
972- raise errors .ConnectionError ("❌ Authentication failed due to server error." )
979+ print (f"❌ Authentication failed: { short_msg } " )
980+ self ._logger .error (short_msg )
981+ raise errors .ConnectionError (f"❌ Authentication failed: { short_msg } " )
973982 else :
974983 self ._logger .warning (f"⚠️ Unexpected message type: { type (message ).__name__ } " )
975984
You can’t perform that action at this time.
0 commit comments