Too Broad of an exception
rsutton
rsutton43 at comcast.net
Wed Oct 25 10:19:43 EDT 2023
Hi all,
I am fairly new to python (ie < 2 years). I have a question about
pylint. I am running on windows 10/11, python 3.10.11.
Here's what I'm trying to do:
I am using robocopy to to copy a set of files to/from a LAN location and
my desktop(s). Here is the partial code:
p = subprocess.run(["robocopy.exe",
STORE_LOCATION, NEWS_LOCATION,
"/NFL", "/NDL", "/NJH", "/NJS", "/NP", "/XF",
"msgFilterRules.dat",
"xmsgFilterRules.dat"], check=False)
# this is necessary because Windows Robocopy returns
# various return codes for success.
if p.returncode >= 8:
raise Exception(f'Invalid result: {p.returncode}')
It actually runs fine. But pylint is not having it. I get:
win_get_put_tb_filters.py:61:12: W0719: Raising too general exception:
Exception (broad-exception-raised)
But the code I have written does exactly what I want. If the returncode
is 7 or less, then I have success. If the returncode is 8 or above
there is a failure and I want to see what the returncode is.
Trying to read the python Exception docs is mind bending. Any help
would be appreciated.
Richard
More information about the Python-list
mailing list