Open mandyWW opened 5 months ago
Yes and no — the buggy editor does have an example of catching the exception here:
Furthermore I learned (the hard way of course, oops) that catching the base Exception
is very counterproductive because it (correctly, but confusingly for newbies) catches their Python syntax errors too, which is why it's now the sql.IoperationalError
there. Note also it's superhelpful that the message includes the exception text:
message = f"Error in update operation: {e}"
But (and it's quite a big but) it's hitherto been deliberate that those two methods (create...
) and (show...
) are not both handling the database accesses the same way: i.e., one provides good except catch, and the other none at all. Ultimately it comes down to just how correct the starting code should be — if we want all database operations to be handled the same way... should be a separate process that is called in call cases maybe.
Students are very to face errors when trying to add a new field to the database. It would be very helpful therefore if
app.py
could include the following so that exceptions are logged: