Skip to content

Commit

Permalink
fix(xmlupload): print reason of failure if resource cannot be created (
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Nov 14, 2023
1 parent d015f9f commit e3a194a
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/dsp_tools/commands/xmlupload/resource_create_client.py
Expand Up @@ -40,17 +40,10 @@ def create_resource(
logger.info(f"Attempting to create resource {resource.id} (label: {resource.label}, iri: {resource.iri})...")
resource_dict = self._make_resource_with_values(resource, bitstream_information)
resource_json_ld = json.dumps(resource_dict, ensure_ascii=False)
try:
res = try_network_action(self.con.post, route="/v2/resources", jsondata=resource_json_ld)
iri = res["@id"]
label = res["rdfs:label"]
return iri, label
except BaseError as e:
msg = f"Could not create resource {resource.id} (label: {resource.label}, iri: {resource.iri})"
raise BaseError(msg) from e
except KeyError as e:
msg = f"Could not create resource {resource.id}: unexpected response from server"
raise BaseError(msg) from e
res = try_network_action(self.con.post, route="/v2/resources", jsondata=resource_json_ld)
iri = res["@id"]
label = res["rdfs:label"]
return iri, label

def _make_resource_with_values(
self,
Expand Down

0 comments on commit e3a194a

Please sign in to comment.