Does anyone know if you can catch os errors in python. I am working on a script that is mapping network drives. If the end user types the name of a path that does not exist no error shows up and that could become an issues. I am using the subprocess module, with python version 3.6, along with the pycharm IDE. If I map to a location that does not exist I get the following error "System error 53 has occurred. The network path was not found."
Lastly I have tried catching the error using OSError, Exception, and BaseException. Each one that I have used does not return any error message.
Here is an example of the script that I am running.
def StoreInfo():
receiving = input("Enter receiving: ")
try:
subprocess.call(r'net use y: \\' + receiving + '\\act\\rto\\transent', shell=True) #timeout=30
except OSError:
#print("An unexpected error:" , sys.exc_info()[0])
print(sending+"'s path does not exit!")
StoreInfo()