Please don't raise an error unless it's a critical failure. Just return None that way the caller knows about the failure and can do something about it like inform the user the file is. It's much simpler to just return None and handle the error in the caller.