Skip to content
Snippets Groups Projects
Commit 18f16ae9 authored by Pablo Garcia Campos's avatar Pablo Garcia Campos
Browse files

utils : fix datacite error formater because a keyerror was raised

parent 10e8aee8
1 merge request!55Resolve "Error raised when publishing a metadata (keyError : source)"
Pipeline #228703 passed
......@@ -34,8 +34,15 @@ def format_error_from_datacite(error: dict) -> str:
:param error: error from datacite
:return: the formated error
"""
try:
description = error["title"].split("]")[1].split(" at line")[0]
except IndexError:
description = error["title"]
return f"\t\u27a5 {error['source']} --> {description}"
if "source" in error and "title" in error:
try:
return (
f"\t\u27a5 {error['source']} --> "
f" {error['title'].split(']')[1].split(' at line')[0]}"
)
except IndexError:
return f"\t\u27a5 {error['source']} --> {error['title']}"
elif "title" in error:
return f"\t\u27a5 {error['title']}"
else:
return f"\t\u27a5 {error}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment