From fe97741f0806409d3bd62cbfee23f2855cd7752a Mon Sep 17 00:00:00 2001 From: Unrud Date: Tue, 6 Jun 2017 20:01:07 +0200 Subject: [PATCH] Better reporting of errors in PUT requests --- radicale/__init__.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 5d3def1..c5bc34e 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -797,13 +797,23 @@ class Application: tag = tags.get(content_type) if write_whole_collection: - new_item = self.Collection.create_collection( - path, items, {"tag": tag}) + try: + new_item = self.Collection.create_collection( + path, items, {"tag": tag}) + except ValueError as e: + self.logger.warning( + "Bad PUT request on %r: %s", path, e, exc_info=True) + return BAD_REQUEST else: if tag: parent_item.set_meta({"tag": tag}) href = posixpath.basename(path.strip("/")) - new_item = parent_item.upload(href, items[0]) + try: + new_item = parent_item.upload(href, items[0]) + except ValueError as e: + self.logger.warning( + "Bad PUT request on %r: %s", path, e, exc_info=True) + return BAD_REQUEST headers = {"ETag": new_item.etag} return client.CREATED, headers, None