Skip to content

fix(client): introduce SocketryError base class; clean up exception hierarchy#36

Merged
jlopez merged 1 commit intomainfrom
fix/issue-33-socketry-error-base-class
Mar 2, 2026
Merged

fix(client): introduce SocketryError base class; clean up exception hierarchy#36
jlopez merged 1 commit intomainfrom
fix/issue-33-socketry-error-base-class

Conversation

@jlopez
Copy link
Owner

@jlopez jlopez commented Mar 2, 2026

Summary

  • Introduces SocketryError(Exception) as the common base for all socketry exceptions
  • AuthenticationError, MqttError, TokenExpiredError, and _SessionInvalidatedError all now inherit from SocketryError instead of RuntimeError or bare Exception
  • MqttError(SocketryError, ConnectionError) retains ConnectionError as a second base so existing except ConnectionError clauses are unaffected
  • SocketryError is exported from the top-level socketry package
  • 7 new tests covering the hierarchy (including TestSocketryErrorExported)

Test plan

  • All 160 tests pass (uv run pytest)
  • mypy, ruff check, ruff format all clean
  • MqttError still satisfies isinstance(e, ConnectionError) (tested)
  • No public exception inherits from RuntimeError (tested)

Fixes: #33

🤖 Generated with Claude Code

…ierarchy

All public and internal exceptions now inherit from SocketryError(Exception)
instead of RuntimeError or bare Exception, giving callers a single typed
catch-all and preventing RuntimeError from leaking as an ambiguous escape.

MqttError(SocketryError, ConnectionError) retains the ConnectionError base
so existing broad except clauses are unaffected.

Fixes: #33
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jlopez jlopez merged commit 20516ec into main Mar 2, 2026
4 checks passed
@jlopez jlopez deleted the fix/issue-33-socketry-error-base-class branch March 2, 2026 17:26
jlopez added a commit that referenced this pull request Mar 2, 2026
### Bug Fixes

* **ci:** update uv.lock on release-please PRs ([#38](#38)) ([f7cf4ad](f7cf4ad))
* **client:** introduce SocketryError base class; clean up exception hierarchy ([#36](#36)) ([20516ec](20516ec)), closes [#33](#33)
* **client:** raise AuthenticationError instead of RuntimeError on login failure ([#34](#34)) ([772e552](772e552)), closes [#32](#32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up exception hierarchy: introduce SocketryError base class

1 participant