Skip to content

Commit d3d234b

Browse files
committed
exc(feat[DeprecatedError]): Add exception class for deprecated APIs
why: Replace deprecation warnings with immediate exceptions to enforce migration to new APIs. what: - Add DeprecatedError exception inheriting from LibTmuxException - Structured constructor with deprecated, replacement, and version params - Clear error message format showing what was deprecated and what to use
1 parent 6dccff6 commit d3d234b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/libtmux/exc.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ class LibTmuxException(Exception):
1919
"""Base Exception for libtmux Errors."""
2020

2121

22+
class DeprecatedError(LibTmuxException):
23+
"""Raised when a deprecated function, method, or parameter is used.
24+
25+
This exception provides clear guidance on what to use instead.
26+
"""
27+
28+
def __init__(
29+
self,
30+
*,
31+
deprecated: str,
32+
replacement: str,
33+
version: str,
34+
) -> None:
35+
msg = (
36+
f"{deprecated} was deprecated in {version} and has been removed. "
37+
f"Use {replacement} instead."
38+
)
39+
super().__init__(msg)
40+
41+
2242
class TmuxSessionExists(LibTmuxException):
2343
"""Session does not exist in the server."""
2444

0 commit comments

Comments
 (0)