I am creating a Python program that requires the use of the OS module, and I would like to custom-report error messages. I am using try and except to accomplish this:
try:
os.mkdir(name)
except FileExistsError:
raise FileExistsError(name + "\n" + " ^ The directory you specified already exists.")
But, I would like to remove the
Traceback (most recent call last):
File "file.py", line 20, in <module>
raise FileExistsError(name + "\n" + " ^ The directory you specified already exists.")
part so that the code that raises this exception is not printed every time that I raise the exception.
How would I go about doing this?