Skip to content

feat(session): derive SessionError from CacheXError - #223

Merged
allen0099 merged 1 commit into
masterfrom
feat/session-error-cachex-base
Sep 26, 2026
Merged

allen0099 merged 1 commit into
masterfrom
feat/session-error-cachex-base

Conversation

@allen0099

Copy link
Copy Markdown
Owner

Closes #162. Part of #113.

SessionError derived from Exception, while StateError derives from CacheXError, so except CacheXError caught state errors but not session errors. It now derives from CacheXError.

  • Handlers for SessionError or Exception keep working. FastAPI/Starlette exception handlers are looked up by the most specific class, so a registered SessionError handler still wins over a CacheXError one.
  • One behaviour change: a try block that lists except CacheXError before except SessionError now takes the CacheXError branch for session errors. The CHANGELOG entry (under ### Changed) says so. No code in the library catches CacheXError.
  • docs/SESSION.md and its zh-TW translation mention the new base class.

Tests

  • New test_session_errors_are_caught_as_cachex_errors in tests/session/test_manager.py. With SessionError reverted to Exception, it is the only test that fails.
  • Full suite, ruff, mypy --strict, the changelog format test and both --strict docs builds pass.

SessionError derived from Exception while StateError derived from
CacheXError, so except CacheXError caught state errors but not session
errors. SessionError still is an Exception, so existing handlers keep
working.

Closes #162
@allen0099
allen0099 merged commit 0ca4fda into master Sep 26, 2026
11 checks passed
@allen0099
allen0099 deleted the feat/session-error-cachex-base branch September 26, 2026 18:53
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.

Derive SessionError from CacheXError

1 participant