diff --git a/src/pylast/__init__.py b/src/pylast/__init__.py index 50c1206a..8495c584 100644 --- a/src/pylast/__init__.py +++ b/src/pylast/__init__.py @@ -932,7 +932,15 @@ def _download_response(self): raise NetworkError(self.network, e) try: - response_text = _unicode(conn.getresponse().read()) + response = conn.getresponse() + if response.status in [500, 502, 503, 504]: + raise WSError( + self.network, + response.status, + "Connection to the API failed with HTTP code " + + str(response.status), + ) + response_text = _unicode(response.read()) except Exception as e: raise MalformedResponseError(self.network, e)