From 9f948df209cdf040f306e7f7889c9c5577d02e7d Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 21 Apr 2022 18:55:00 +0200 Subject: [PATCH] add always response 201 --- ereuse_devicehub/api/views.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/api/views.py b/ereuse_devicehub/api/views.py index 7a894394..57796675 100644 --- a/ereuse_devicehub/api/views.py +++ b/ereuse_devicehub/api/views.py @@ -53,7 +53,14 @@ class InventoryView(LoginMix, SnapshotMix): snapshot_json = self.validate(snapshot_json) try: self.snapshot_json = ParseSnapshotLsHw(snapshot_json).get_snapshot() - except ValidationError: + except Exception as err: + txt = "{}, {}".format(err.__class__, err) + uuid = snapshot_json.get('uuid') + wbid = snapshot_json.get('wbid') + error = SnapshotErrors( + description=txt, snapshot_uuid=uuid, severity=Severity.Error, wbid=wbid + ) + error.save(commit=True) self.response = jsonify('') self.response.status_code = 201 return self.response