diff --git a/dcos/cosmospackage.py b/dcos/cosmospackage.py index fce6659..8135d2e 100644 --- a/dcos/cosmospackage.py +++ b/dcos/cosmospackage.py @@ -37,10 +37,14 @@ class Cosmos(): # authorized for the command specified, not this endpoint except DCOSAuthorizationException: return True - # all other errors are treated as endpoint not available + # allow exception through so we can show user actual http exception + # except 404, because then the url is fine, just not cosmos enabled + except DCOSHTTPException as e: + logger.exception(e) + return e.status() != 404 except Exception as e: logger.exception(e) - return False + return True return response.status_code == 200 diff --git a/dcos/errors.py b/dcos/errors.py index fb9821f..9c8e06a 100644 --- a/dcos/errors.py +++ b/dcos/errors.py @@ -14,6 +14,9 @@ class DCOSHTTPException(DCOSException): def __init__(self, response): self.response = response + def status(self): + return self.response.status_code + def __str__(self): return 'Error while fetching [{0}]: HTTP {1}: {2}'.format( self.response.request.url,