tailot's picture
Upload folder using huggingface_hub
db2c7db verified
Raw History Blame Contribute Delete
462 Bytes
"""Failure handling around an object that reads.
One handler catches every exception the interpreter can raise, and that is the shape
the narrow exception pattern rewrites. The other handler already names its exception,
and the pattern says so.
"""
def call_or_none(source):
try:
return source.read()
except:
return ""
def call_or_note(source):
try:
return source.read()
except ValueError:
return "no source"