File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -621,6 +621,15 @@ async def _snapshot_via_api(
621621 # Re-raise validation errors as-is
622622 raise
623623 except Exception as e :
624+ # Preserve structured gateway details when available.
625+ try :
626+ from ..snapshot import SnapshotGatewayError # type: ignore
627+
628+ if isinstance (e , SnapshotGatewayError ):
629+ raise
630+ except Exception :
631+ pass
632+
624633 # Fallback to local extension on API error
625634 # This matches the behavior of the main snapshot function
626635 raise RuntimeError (
Original file line number Diff line number Diff line change @@ -96,6 +96,16 @@ def from_httpx(cls, e: Exception) -> "SnapshotGatewayError":
9696 body_snip = cls ._snip (body )
9797 if body_snip :
9898 bits .append (f"body={ body_snip } " )
99+ # If we don't have an HTTP status/response body, this is usually a transport error
100+ # (timeout, DNS, connection reset). Preserve at least the exception type + message.
101+ if status_code is None and not body_snip :
102+ try :
103+ err_s = cls ._snip (str (e ), 220 )
104+ except Exception :
105+ err_s = None
106+ bits .append (f"err_type={ type (e ).__name__ } " )
107+ if err_s :
108+ bits .append (f"err={ err_s } " )
99109 if bits :
100110 msg = f"{ msg } : " + " " .join (bits )
101111 msg = msg + ". Try using use_api=False to use local extension instead."
@@ -144,6 +154,14 @@ def from_requests(cls, e: Exception) -> "SnapshotGatewayError":
144154 body_snip = cls ._snip (body )
145155 if body_snip :
146156 bits .append (f"body={ body_snip } " )
157+ if status_code is None and not body_snip :
158+ try :
159+ err_s = cls ._snip (str (e ), 220 )
160+ except Exception :
161+ err_s = None
162+ bits .append (f"err_type={ type (e ).__name__ } " )
163+ if err_s :
164+ bits .append (f"err={ err_s } " )
147165 if bits :
148166 msg = f"{ msg } : " + " " .join (bits )
149167 msg = msg + ". Try using use_api=False to use local extension instead."
You can’t perform that action at this time.
0 commit comments