Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use 'raise exc from None' because it suppresses exception causes #1158

Merged
merged 1 commit into from Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion starlette/endpoints.py
Expand Up @@ -71,7 +71,7 @@ async def dispatch(self) -> None:
break
except Exception as exc:
close_code = status.WS_1011_INTERNAL_ERROR
raise exc from None
raise exc
finally:
await self.on_disconnect(websocket, close_code)

Expand Down
2 changes: 1 addition & 1 deletion starlette/exceptions.py
Expand Up @@ -79,7 +79,7 @@ async def sender(message: Message) -> None:
handler = self._lookup_exception_handler(exc)

if handler is None:
raise exc from None
raise exc

if response_started:
msg = "Caught handled exception, but response already started."
Expand Down
2 changes: 1 addition & 1 deletion starlette/middleware/errors.py
Expand Up @@ -178,7 +178,7 @@ async def _send(message: Message) -> None:
# We always continue to raise the exception.
# This allows servers to log the error, or allows test clients
# to optionally raise the error within the test case.
raise exc from None
raise exc

def format_line(
self, index: int, line: str, frame_lineno: int, frame_index: int
Expand Down
2 changes: 1 addition & 1 deletion starlette/testclient.py
Expand Up @@ -240,7 +240,7 @@ async def send(message: Message) -> None:
loop.run_until_complete(self.app(scope, receive, send))
except BaseException as exc:
if self.raise_server_exceptions:
raise exc from None
raise exc

if self.raise_server_exceptions:
assert response_started, "TestClient did not receive any response."
Expand Down