Closed felixvd closed 1 year ago
The build is failing because there's invalid syntax in the file. If we don't raise an exception, then users might assume that everything has been documented correctly, when actually the file with the offending syntax error won't have been documented. Why is catching all exceptions beneficial?
If we don't raise an exception, then users might assume that everything has been documented correctly
I am not sure I can follow your argument. Not raising an exception is the current behavior when catching IOError
, TypeError
, ImportError
. They all cause files not to be documented and only log a warning. If you say this is undesirable, the current code should be fixed, e.g. like this:
- except (IOError, TypeError, ImportError):
+ except (IOError, TypeError, ImportError) as e:
LOGGER.debug("Reason:", exc_info=True)
LOGGER.warning(
"Unable to read file: {0}".format(path),
type="autoapi",
subtype="not_readable",
)
+ raise e
return None
I can add the raise e
line to this PR if you prefer.
Why is catching all exceptions beneficial?
Importing a file with this content:
Results in an extremely unhelpful error message that does not mention the offending file:
This change fixes the behavior.
For the record, the
Exception
that was not caught was of typeastroid.exceptions.AstroidSyntaxError
.