hrrmsn / ffcleaner

cmd tool to cleanup littered directories (Files&Folders cleaner)
0 stars 0 forks source link

Add exception handling #6

Open hrrmsn opened 8 years ago

hrrmsn commented 8 years ago

Related links are below. https://jeffknupp.com/blog/2013/02/06/write-cleaner-python-use-exceptions/ (read) https://www.joelonsoftware.com/2003/10/13/13/ (read) http://eli.thegreenplace.net/2008/08/21/robust-exception-handling/ (read) https://docs.python.org/2.7/tutorial/errors.html (read)

hrrmsn commented 7 years ago

I learned that EAFP style is better than LBYL style when you write in python.

hrrmsn commented 7 years ago

Following article is look a quite interesting for my purpose. http://stackoverflow.com/questions/1591319/python-how-can-i-know-which-exceptions-might-be-thrown-from-a-method-call

I learned that unit tests is a good way to find exceptions which can be thrown by my code.

hrrmsn commented 7 years ago

Source code for python 'os' module. (Look for the exception handling examples.) https://hg.python.org/cpython/file/2.7/Lib/os.py

'zipfile' module source code. https://hg.python.org/cpython/file/2.7/Lib/zipfile.py

hrrmsn commented 7 years ago

List of python exceptions. https://docs.python.org/2/library/exceptions.html

hrrmsn commented 7 years ago

I must read this article. http://stackoverflow.com/questions/10594113/bad-idea-to-catch-all-exceptions-in-python (read)

hrrmsn commented 7 years ago

I'm tired from reading docs and articles. It's time for programming now! Just code stupid pig. ( :

hrrmsn commented 7 years ago

Useful links. (Look for the response code. I need to verify success of the 'post' method calling.) http://stackoverflow.com/questions/11322430/python-how-to-send-post-request http://stackoverflow.com/questions/15258728/requests-how-to-tell-if-youre-getting-a-404

hrrmsn commented 7 years ago

'OSError' occurs if i delete directory for cleaning when script is still working! ('plungedir' function need to be surrounded by try-except block.)

hrrmsn commented 7 years ago

I think that the better idea is write detail info about the exception into the log. CLI is for small messages. (Like 'started cleaning', current progress output etc. Such messages is ok.)

Described suggestion isn't implemented yet!