3 ms·
Yes, I would do that in nearly every case. However, I don't know the larger context. If this were at the top-level of a web services handler where a "return No
by dalke 12y ago
Yes, I would do that in nearly every case.
However, I don't know the larger context. If this were at the top-level of a web services handler where a "return None" indicates a 400 - Internal Server Error, then logging the database failure and stopping is likely acceptable.
Even then, I wouldn't call it good code. However, the goal of this essay seemed to be to give the minimal example, and a more complete example would have required introducing a fake database module with its own exception type. I believe that would have obscured the intent.
I would have preferred real, working code. In this case, with sqlite3. That's fundamentally a pedagogical choice though.