Dev-iL commented on code in PR #59879:
URL: https://github.com/apache/airflow/pull/59879#discussion_r2650577739


##########
dev/breeze/src/airflow_breeze/utils/selective_checks.py:
##########
@@ -1409,7 +1409,11 @@ def get_job_label(self, event_type: str, branch: str):
 
         response = requests.get(url, headers=headers, params=payload)
         if response.status_code != 200:
-            get_console().print(f"[red]Error while listing workflow runs 
error: {response.json()}.\n")
+            try:
+                error_msg = response.json()
+            except requests.exceptions.JSONDecodeError:

Review Comment:
   I understand that using a builtin exception class allows us to avoid a 3rd 
party import. However, does it not improve readability when we're explicit 
about the error we're catching (i.e. "not an arbitrary value error but one 
that's specific to json decoding")?
   
   Also, could you please explain why specifically `ValueError` is preferred in 
this case? `IOError` is technically suitable too.
   
   Requests exceptions are defined as follows:
   ```python
   class RequestException(IOError):
   
   class InvalidJSONError(RequestException):
   
   class CompatJSONDecodeError(ValueError):  # originally `JSONDecodeError`, 
imported as `CompatJSONDecodeError`
   
   class JSONDecodeError(InvalidJSONError, CompatJSONDecodeError):
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to