You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The exception handling appears to be routing generic exceptions (i.e. Exception) through custom exceptions (i.e. ApiError) however in doing so it is passing response which may have failed to assign.
Take the following example:
try:
response = self._session.post(uri, json=data, headers=headers)
# Validate the response
self._check_response_code(response, DEFAULT_SUCCESS_RESPONSE_CODES)
self._print_debug_response(response)
except Exception:
> raise ApiError(response)
E UnboundLocalError: local variable 'response' referenced before assignment
In this case if self._session.post excepts, then response will not be assigned and we do not get proper exception handling. There are a few different approaches that can be taken here (one of which would be to initialize response to None and then handle this accordingly).
The text was updated successfully, but these errors were encountered:
The exception handling appears to be routing generic exceptions (i.e.
Exception
) through custom exceptions (i.e.ApiError
) however in doing so it is passingresponse
which may have failed to assign.Take the following example:
In this case if
self._session.post
excepts, thenresponse
will not be assigned and we do not get proper exception handling. There are a few different approaches that can be taken here (one of which would be to initialize response to None and then handle this accordingly).The text was updated successfully, but these errors were encountered: