Skip to content

Commit

Permalink
Merge pull request #70 from neicnordic/bugfix/some-error-msg
Browse files Browse the repository at this point in the history
fix fail not proper error message handling
  • Loading branch information
blankdots authored Sep 19, 2022
2 parents 48dc0a8 + 374b614 commit 6704e00
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 6704e00

Please sign in to comment.