Skip to content

Commit 30fba8a

Browse files
committed
Hardcode 502 in APIBadGateway instead of accepting a status_code
The class definitionally represents a 502, so there is no reason for construction sites to pass (or be able to override) the status.
1 parent c0ac850 commit 30fba8a

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

socketdev/core/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def format_headers(headers_dict):
112112
raise APIInsufficientQuota(status_code=429)
113113
if response.status_code == 502:
114114
log.error(f"Upstream server error{path_str}{headers_str}")
115-
raise APIBadGateway(status_code=502)
115+
raise APIBadGateway()
116116
if response.status_code >= 400:
117117
try:
118118
error_json = response.json()

socketdev/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@ def is_transient_error(self) -> bool:
7676
class APIBadGateway(APIFailure):
7777
"""Raised when the upstream server returns a 502 Bad Gateway error"""
7878

79-
def __init__(self, *args, status_code: Optional[int] = 502):
80-
super().__init__(*args, status_code=status_code)
79+
def __init__(self, *args):
80+
super().__init__(*args, status_code=502)

0 commit comments

Comments
 (0)