Skip to content

Commit 088dd65

Browse files
authored
Merge pull request #381 from simvue-io/hotfix/add-url-to-validation-out
Add URL to server validation response
2 parents 4870a3b + 14c522a commit 088dd65

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

simvue/api.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,22 @@ def post(
8383
if response.status_code == 422:
8484
_parsed_response = parse_validation_response(response.json())
8585
raise ValueError(
86-
f"Validation error [{response.status_code}]:\n{_parsed_response}"
86+
f"Validation error for '{url}' [{response.status_code}]:\n{_parsed_response}"
8787
)
8888

8989
if response.status_code not in (200, 201, 409):
90-
raise RuntimeError(f"HTTP error [{response.status_code}]: {response.text}")
90+
raise RuntimeError(
91+
f"HTTP error for '{url}' [{response.status_code}]: {response.text}"
92+
)
9193

9294
return response
9395

9496

9597
@retry(
9698
wait=wait_exponential(multiplier=RETRY_MULTIPLIER, min=RETRY_MIN, max=RETRY_MAX),
97-
# retry=retry_if_not_exception_message(match="Validation error"), # if validation failed no point in retrying
99+
retry=retry_if_exception_type(RuntimeError),
98100
stop=stop_after_attempt(RETRY_STOP),
101+
reraise=True,
99102
)
100103
def put(
101104
url: str,
@@ -104,7 +107,7 @@ def put(
104107
is_json: bool = True,
105108
timeout: int = DEFAULT_API_TIMEOUT,
106109
) -> requests.Response:
107-
"""HTTP POST with retries
110+
"""HTTP PUT with retries
108111
109112
Parameters
110113
----------

0 commit comments

Comments
 (0)