Skip to content

Commit 9d5e1f6

Browse files
broden-wannerBrodyWanner
andauthored
Added error propagation to gateway_request function (#1233)
Co-authored-by: BrodyWanner <[email protected]>
1 parent 4513527 commit 9d5e1f6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

jupyter_server/gateway/gateway_client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,19 @@ async def gateway_request(endpoint: str, **kwargs: ty.Any) -> HTTPResponse:
728728
# NOTE: We do this here since this handler is called during the server's startup and subsequent refreshes
729729
# of the tree view.
730730
except HTTPClientError as e:
731+
error_reason = f"Exception while attempting to connect to Gateway server url '{GatewayClient.instance().url}'"
732+
error_message = e.message
733+
if e.response:
734+
try:
735+
error_payload = json.loads(e.response.body)
736+
error_reason = error_payload.get("reason") or error_reason
737+
error_message = error_payload.get("message") or error_message
738+
except json.decoder.JSONDecodeError:
739+
error_reason = e.response.body.decode()
740+
731741
raise web.HTTPError(
732742
e.code,
733-
f"Error attempting to connect to Gateway server url '{GatewayClient.instance().url}'. "
743+
f"Error from Gateway: [{error_message}] {error_reason}. "
734744
"Ensure gateway url is valid and the Gateway instance is running.",
735745
) from e
736746
except ConnectionError as e:

0 commit comments

Comments
 (0)