Open hrrmsn opened 8 years ago
I learned that EAFP style is better than LBYL style when you write in python.
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.
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
List of python exceptions. https://docs.python.org/2/library/exceptions.html
I must read this article.
http://stackoverflow.com/questions/10594113/bad-idea-to-catch-all-exceptions-in-python (read)
I'm tired from reading docs and articles. It's time for programming now! Just code stupid pig. ( :
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
'OSError' occurs if i delete directory for cleaning when script is still working! ('plungedir' function need to be surrounded by try-except block.)
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!
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)