Blog
Python SDK Exception Hooks That Still Raise
Report Python SDK failures from your own boundary. Do not replace sys.excepthook. Log the code and stack, then re-raise so the caller's program behaves exactly as it did before you instrumented it.
2026-10-12 · 7 min read · AethelLayer
excepthook belongs to the application
sys.excepthook and threading.excepthook are process-wide. A library that replaces them will surprise every other dependency and can hide SystemExit or KeyboardInterrupt if it is careless. Instrument the methods you document.
Catch at the boundary, emit the probe, and raise the same exception with the original traceback. from None is the wrong tool here. You want the chain preserved.
What the probe is allowed to hold
Exception type, stable code, message with secrets stripped, stack, interpreter version, OS, and package version. Not os.environ. Not the full request. Not a pickle of the frame locals.
Locals are where tokens sit. If you ever snapshot variables, allow-list names like status_code and endpoint. Default to no locals.
CLIs can prompt. Libraries cannot.
If the SDK is imported by a web worker, input() will hang the worker. Gate the question 'What were you trying to do?' on an explicit CLI mode and a TTY. Everyone else gets a silent probe.
Exit status still comes from the CLI, not from the library. Map your exception types to the documented codes and let main() call sys.exit.
Group by code, quote the human
A week of ConnectionError messages will not tell you whether the quickstart URL is wrong. The code plus the one sentence will. Draft the issue with both, and let a person send it.
When the same code dominates, fix the sample or the default timeout. Do not wait for someone to paste a traceback into Discord.
Keep reading
Capture the failure before they leave
Capture the failure before they leave. Book early access or talk to sales, then install @aethellayer/sdk when you are onboarded.