Skip to content

Commit

Permalink
Catch ODK and Enketo validation errors on deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
noliveleger committed Jan 14, 2025
1 parent 9189ac9 commit 760d17e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion kpi/serializers/v2/deployment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.conf import settings
from pyxform.errors import PyXFormError
from pyxform.validators.enketo_validate import EnketoValidateError
from pyxform.validators.odk_validate import ODKValidateError
from rest_framework import serializers
from xlsxwriter.exceptions import DuplicateWorksheetName

Expand Down Expand Up @@ -36,7 +38,12 @@ def create(self, validated_data):
# 'deployed' boolean value
try:
asset.deploy(backend=backend_id, active=validated_data.get('active', False))
except (DuplicateWorksheetName, PyXFormError) as e:
except (
DuplicateWorksheetName,
EnketoValidateError,
PyXFormError,
ODKValidateError,
) as e:
raise serializers.ValidationError({'error': str(e)})
return asset.deployment

Expand Down

0 comments on commit 760d17e

Please sign in to comment.