Skip to content

Commit fe6aa25

Browse files
committed
Improved the handling of failed xml2rfc conversions when no txt document was submitted.
- Legacy-Id: 9914
1 parent 1fb8f5a commit fe6aa25

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

ietf/submit/views.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ def upload_submission(request):
4747

4848
if form.cleaned_data['xml']:
4949
if not form.cleaned_data['txt']:
50+
file_name['txt'] = os.path.join(settings.IDSUBMIT_STAGING_PATH, '%s-%s.txt' % (form.filename, form.revision))
5051
try:
51-
file_name['txt'] = os.path.join(settings.IDSUBMIT_STAGING_PATH, '%s-%s.txt' % (form.filename, form.revision))
5252
pagedwriter = xml2rfc.PaginatedTextRfcWriter(form.xmltree, quiet=True)
5353
pagedwriter.write(file_name['txt'])
54-
file_size = os.stat(file_name['txt']).st_size
5554
except Exception as e:
56-
raise ValidationError("Exception: %s" % e)
55+
raise ValidationError("Error from xml2rfc: %s" % e)
56+
file_size = os.stat(file_name['txt']).st_size
5757
# Some meta-information, such as the page-count, can only
5858
# be retrieved from the generated text file. Provide a
5959
# parsed draft object to get at that kind of information.
@@ -128,6 +128,10 @@ def upload_submission(request):
128128
form._errors["__all__"] = form.error_class(["There was a failure receiving the complete form data -- please try again."])
129129
else:
130130
raise
131+
except ValidationError as e:
132+
form = SubmissionUploadForm(request=request)
133+
form._errors = {}
134+
form._errors["__all__"] = form.error_class(["There was a failure converting the xml file to text -- please verify that your xml file is valid. (%s)" % e.message])
131135
else:
132136
form = SubmissionUploadForm(request=request)
133137

0 commit comments

Comments
 (0)