Skip to content

Commit

Permalink
fix fail not proper error message handling
Browse files Browse the repository at this point in the history
  • Loading branch information
blankdots committed Sep 15, 2022
1 parent 48dc0a8 commit 374b614
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sda_orchestrator/utils/id_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ async def create_draft_doi(self, user: str, inbox_path: str) -> Union[Dict, None
"dataset": f"{self.ns_url}/{_suffix.lower()}",
}
else:
LOG.debug(f"DOI draft created and response was: {response}")
LOG.error(f"DOI API create draft request failed with code: {response.status_code}")
doi_data = self._check_errors(response, doi_suffix)

Expand Down Expand Up @@ -182,7 +183,7 @@ def _check_errors(self, response: Response, doi_suffix: str) -> Union[Dict, None
doi_data = None
if len(errors_resp) == 1:
error_msg = errors_resp[0]["title"] if "title" in errors_resp[0] else errors_resp[0]["detail"]
if errors_resp[0]["source"] == "doi" and error_msg == "This DOI has already been taken":
if "source" in errors_resp[0] and error_msg == "This DOI has already been taken":
LOG.info("DOI already taken, we will associate the submission to this doi dataset.")
doi_data = {
"suffix": doi_suffix,
Expand Down

0 comments on commit 374b614

Please sign in to comment.