CSSG-Labs / PyNote

Text Editor Written in Python
GNU General Public License v3.0
3 stars 4 forks source link

Fix FileNotFoundError #11

Closed PatrickBruso closed 2 years ago

PatrickBruso commented 2 years ago

When saving the text box, if the user opens the save file dialog but then cancels the file dialog box, the program will throw a FileNotFoundError. We need to write a try/except handle for saving the text which will catch when a user cancels the dialog, tries to save a file with an unsupported file name, or tries to save a file to a directory that does not exist. See the errors section of the python docs for more information on handling exceptions.

AdamLaine commented 2 years ago

@PatrickBruso I also saw this bug. Try/except is a good option, but I would like to suggest using just the more conservative if-clause. The reason is the following: due to the dialogue window used one physically shouldn't be able to provide an illegal filename (I tried), therefore the only thing to look for is an empty string (which also causes the error), which can be easily managed without an error handler as the most logical option here in my opinion is just to ignore it when it happens. Tell me what do you think.

PatrickBruso commented 2 years ago

@SamReiCooper Sounds good, I'll take a look at the PR today. Also, don't forget to assign yourself to any issues that you're working on so we don't have multiple people working on the same issue.

AdamLaine commented 2 years ago

@PatrickBruso I'm afraid I don't have the permission to assign myself issues (at least I don't have these options enabled and the stackoverflow answer tells me the same https://stackoverflow.com/questions/26752902/how-to-assign-issue-to-myself-at-github#26761256). So, I'll have to rely for now on alternative methods (when I take an issue I can leave a comment if you wish, for example) or you can give some limited permission, if there's this possibility (otherwise I can just leave comments)

PatrickBruso commented 2 years ago

@SamReiCooper thanks for letting me know, I added you as a collaborator so you should be able to assign yourself an issue but if not let me know. I'm not super familiar with all of the designations but I think the one I gave you should give you that permission.

AdamLaine commented 2 years ago

@PatrickBruso Yes, now I have the permission, thank you

PatrickBruso commented 2 years ago

This was fixed via PR. I forgot to link them so I'll close it now.