@@ -139,21 +139,21 @@ def test_connection():
139139        return  jsonify (result )
140140
141141    except  Exception  as  e :
142-         error_msg  =  str (e )
143-         print (f"Test connection error: { error_msg }  )
142+         print (f"Test connection error: { str (e )}  )
144143        print (traceback .format_exc ())
145144
146-         # Provide more specific error messages 
147-         if  'timeout'  in  error_msg .lower ():
148-             error_msg  =  'Connection timed out. Please check your DirectAdmin server URL and network connection.' 
149-         elif  'connection'  in  error_msg .lower ():
150-             error_msg  =  'Unable to connect to DirectAdmin server. Please verify the server URL is correct.' 
151-         elif  'ssl'  in  error_msg .lower () or  'certificate'  in  error_msg .lower ():
152-             error_msg  =  'SSL certificate error. Try using HTTP instead of HTTPS, or check your certificate configuration.' 
145+         # Provide more specific error messages to the user, do not return exception messages 
146+         user_error_msg  =  None 
147+         error_str  =  str (e ).lower ()
148+         if  'timeout'  in  error_str :
149+             user_error_msg  =  'Connection timed out. Please check your DirectAdmin server URL and network connection.' 
150+         elif  'connection'  in  error_str :
151+             user_error_msg  =  'Unable to connect to DirectAdmin server. Please verify the server URL is correct.' 
152+         elif  'ssl'  in  error_str  or  'certificate'  in  error_str :
153+             user_error_msg  =  'SSL certificate error. Try using HTTP instead of HTTPS, or check your certificate configuration.' 
153154        else :
154-             error_msg  =  f'Connection test failed: { error_msg }  
155-             
156-         return  jsonify ({'error' : error_msg , 'success' : False }), 200 
155+             user_error_msg  =  'Connection test failed. Please contact support or try again later.' 
156+         return  jsonify ({'error' : user_error_msg , 'success' : False }), 200 
157157
158158@settings_bp .route ('/api/domains' , methods = ['GET' ]) 
159159@login_required  
0 commit comments