How to capture Exception in python scripting for new_server function?

I tried to capture the exception case with the following code when the function of new_server is called with wrong scrpting server port ID or password. 

========================================================================================

try:
   s_o, g_o = new_server('localhost', outputport, password=outpass, error_mode=(RAISE))
except:
   msgbox("Warning: the supplied scripting server port ID or password is not correct.")
   sys.exit()

========================================================================================

However, it seems that the exception does happen even when I provide the correct port ID and password. Not sure how to get it to work. Thanks for help in advance. 

Also, is it possible tp reset the port ID / password for the scripting server within the python code in the middle of the process? For example, after some tasks are completed, those settings will be re-set for the following tasks.