Suppress parsing errors
demalexx opened this issue · comments
Now if there is error during parsing robots.txt
, reppy outputs it like this:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/reppy/ttl.py", line 60, in ttl
return max(self.minimum, parse_date(expires) - date)
File "/usr/local/lib/python3.4/dist-packages/reppy/util.py", line 10, in parse_date
raise ValueError("Invalid time.")
ValueError: Invalid time.
This isn't exception that could be handled by client code. Would be nice to have a way to suppress this error, or redirect somewhere else.
Thank you for the bug report. What version of reppy
are you using? Looking at the current code, line 60 appears to already be wrapped in a try
/except
block for ValueError
already.
Yes, it's wrapped in try/except. I mean it puts log message to console. Probably to avoid that message I just need to mute reppy logger somehow.
@demalexx you could set the logging level for reppy
to CRITICAL
, or remove all the handlers from that logging object (https://stackoverflow.com/a/7484605/173556)
I'm thinking these log lines should probably be demoted to logging.warn
rather than logging.exception
which defaults to the ERROR level.