2 ms·
In a larger codebase, a combination of both would be more helpful. With the last one, you're not getting the same view as with the latter, and in a large codeba
by diggan 6y ago
In a larger codebase, a combination of both would be more helpful. With the last one, you're not getting the same view as with the latter, and in a large codebase where the error could be triggered from many directions, it would be better to have the first example, at least in my experience.
Traceback (most recent call last):
File "/var/prod/deadbeef/models/sql/peers.py", line 1337, in tx
db.execute()
File "/var/prod/deadbeef/models/sql/session.py", line 1337, in session
tx(peers.add(a, b))
File "/var/prod/deadbeef/models/__init__.py", line 1337, in AddBGPPeer
session(peers, AddPeers(a, b))
File "/var/prod/deadbeef/views.py", line 1337, in _view_add_peer
AddBGPPeer(user, other)
File "/var/prod/deadbeef/web.py", line 1337, in handle
_view_add_peer(ctx)
Exception: Failed to add peer: models.AddBGPPeer(204480, 204480): insert peer: tx aborted: unique constraint failed
- q3k 6y agoAbsolutely. I'm not saying exceptions are bad and harmful, I'm saying that exceptions aren't an automatic solution to good error handling.