I believe I've found an inconsistency in the connector’s structured error-handling flow and wanted maintainer feedback before opening a PR.
The connection/cursor errorhandler typing is looser and less explicit than the structured Error-based contract used in errors.py. There is also a mismatch in the ready-exception path: generic Python exceptions can be routed into the structured handler flow even though that flow expects structured error details rather than Exception.args-style payloads.
I prepared a branch with a proposed fix:
- branch:
typing-errorhandler-protocol
The change does the following:
- introduces a shared structured payload type for error-handler details
- introduces a shared structured handler protocol
- aligns
connection.py and cursor.py with that structured contract
- narrows the structured path to
Error subclasses
- updates the ready-exception wrapper so generic exceptions are re-raised instead of being routed into the dict-based structured handler flow
- adds unit tests for the structured and ready-exception paths
Before opening the PR, I wanted to confirm:
- whether maintainers agree this should be treated as an internal bug/consistency fix
- whether narrowing the structured path to
Error subclasses is the right direction
- whether this should go in as one PR or be split into smaller pieces
I believe I've found an inconsistency in the connector’s structured error-handling flow and wanted maintainer feedback before opening a PR.
The connection/cursor errorhandler typing is looser and less explicit than the structured
Error-based contract used inerrors.py. There is also a mismatch in the ready-exception path: generic Python exceptions can be routed into the structured handler flow even though that flow expects structured error details rather thanException.args-style payloads.I prepared a branch with a proposed fix:
typing-errorhandler-protocolThe change does the following:
connection.pyandcursor.pywith that structured contractErrorsubclassesBefore opening the PR, I wanted to confirm:
Errorsubclasses is the right direction