diff --git a/dds_cli/data_getter.py b/dds_cli/data_getter.py index 4dd80c1c..78af7c37 100644 --- a/dds_cli/data_getter.py +++ b/dds_cli/data_getter.py @@ -221,15 +221,20 @@ def update_db(self, file): params = {"project": self.project} # Send file info to API - response_json, _ = dds_cli.utils.perform_request( - DDSEndpoint.FILE_UPDATE, - method="put", - params=params, - json=filename, - headers=self.token, - error_message="Failed to update file information", - ) - - updated_in_db, message = (True, response_json["message"]) + try: + response_json, _ = dds_cli.utils.perform_request( + DDSEndpoint.FILE_UPDATE, + method="put", + params=params, + json=filename, + headers=self.token, + error_message="Failed to update file information", + ) + except dds_cli.exceptions.ApiRequestError as err: + updated_in_db = False + message = str(err) + else: + updated_in_db = True + message = response_json["message"] return updated_in_db, message diff --git a/dds_cli/utils.py b/dds_cli/utils.py index 1b004537..5a7ed90a 100644 --- a/dds_cli/utils.py +++ b/dds_cli/utils.py @@ -5,6 +5,7 @@ import typing import http from typing import Dict, List, Union +import logging import requests import rich.console @@ -201,11 +202,11 @@ def transform_paths(json_input): ) except requests.exceptions.RequestException as err: if isinstance(err, requests.exceptions.ConnectionError): - error_message += ": The database seems to be down." + error_message += f": The database seems to be down -- \n{err}" elif isinstance(err, requests.exceptions.Timeout): error_message += ": The request timed out." else: - error_message += f": Unknown request error -- \n {err}" + error_message += f": Unknown request error -- \n{err}" raise dds_cli.exceptions.ApiRequestError(message=error_message) # Get and parse project specific errors