clan-app: full context tracebacks
If an exception now is thrown in one of the middlewares we will get a proper traceback instead of a cut off one like before
This commit is contained in:
@@ -12,6 +12,25 @@ class MiddlewareContext:
|
||||
request: "BackendRequest"
|
||||
bridge: "ApiBridge"
|
||||
exit_stack: ExitStack
|
||||
original_traceback: list[str]
|
||||
|
||||
|
||||
class MiddlewareError(Exception):
|
||||
"""Exception that preserves original calling context."""
|
||||
|
||||
def __init__(
|
||||
self, message: str, original_frames: list[str], original_error: Exception
|
||||
) -> None:
|
||||
# Store just the original error message for API responses
|
||||
super().__init__(str(original_error))
|
||||
self.method_message = message
|
||||
self.original_frames = original_frames
|
||||
self.original_error = original_error
|
||||
|
||||
def __str__(self) -> str:
|
||||
# For traceback display, show in proper Python traceback order (oldest to newest)
|
||||
original_context = "".join(self.original_frames)
|
||||
return f"Traceback (most recent call last):\n{original_context.rstrip()}\nMethodExecutionError: {self.original_error}"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
||||
Reference in New Issue
Block a user