While hacking together a Save as Copy menu method, I noticed that the code has lots of open or unspecified 'except' statements. My experience has been that when I use a try ... except statement, I need to follow the 'except' with the type of error I am expecting to trap.. Otherwise, it's possible that the exception will be handled by another 'except' statement elsewhere in the app, which makes it *really* hard to pin down. Ask me how I know this!
So, for file operations, like Save As Copy, I used 'except IOError'; if I were converting a string to int, I might use 'except TypeError', and so on.
While hacking together a Save as Copy menu method, I noticed that the code has lots of open or unspecified 'except' statements. My experience has been that when I use a try ... except statement, I need to follow the 'except' with the type of error I am expecting to trap.. Otherwise, it's possible that the exception will be handled by another 'except' statement elsewhere in the app, which makes it *really* hard to pin down. Ask me how I know this!
So, for file operations, like Save As Copy, I used 'except IOError'; if I were converting a string to int, I might use 'except TypeError', and so on.
Comments?
---
try:
shutil.copyfile(self.txtDocument.filename, cfilename)
except IOError:
doStuff()
cheers
Stewart
Was this resolved?
Your code worked fine for me.
(Although PLEASE email it, or attach it to patches on the main project page)
Very useful feature to add.