Use ValidationError when appropriate.

This commit is contained in:
Tom Hacohen 2020-12-28 18:49:05 +02:00
parent f0a8689712
commit 7714148807

View File

@ -285,7 +285,7 @@ def process_revisions_for_item(item: models.CollectionItem, revision_data: Colle
chunk_obj.chunkFile.save("IGNORED", ContentFile(content)) chunk_obj.chunkFile.save("IGNORED", ContentFile(content))
chunk_obj.save() chunk_obj.save()
else: else:
raise HttpError("chunk_no_content", "Tried to create a new chunk without content") raise ValidationError("chunk_no_content", "Tried to create a new chunk without content")
chunks_objs.append(chunk_obj) chunks_objs.append(chunk_obj)
@ -301,7 +301,7 @@ def process_revisions_for_item(item: models.CollectionItem, revision_data: Colle
def _create(data: CollectionIn, user: User): def _create(data: CollectionIn, user: User):
with transaction.atomic(): with transaction.atomic():
if data.item.etag is not None: if data.item.etag is not None:
raise HttpError("bad_etag", "etag is not null") raise ValidationError("bad_etag", "etag is not null")
instance = models.Collection(uid=data.item.uid, owner=user) instance = models.Collection(uid=data.item.uid, owner=user)
try: try:
instance.validate_unique() instance.validate_unique()