# HG changeset patch # User Bernhard Herzog # Date 1493405782 -7200 # Node ID 2ef34abbad8d7428a3f9f2662c5b1324f205363e # Parent 48dabf4bf680b55fd50512e2af96980e1a01e427 Use http error code 422 in CheckView when a merge is not possible. Previously the response used the code 500 in this case. This is not useful because it's not an internal server error when the check whether a PDF file can be merged fails because that's the point of the CheckView. The code used now means "Unprocessable Entity" and fits better. Part of mpuls/issue6009 diff -r 48dabf4bf680 -r 2ef34abbad8d odfcast/convert.py --- a/odfcast/convert.py Fri Apr 28 19:06:14 2017 +0200 +++ b/odfcast/convert.py Fri Apr 28 20:56:22 2017 +0200 @@ -246,6 +246,14 @@ return render_template("check.html") def post(self): + """Check that the attached PDF file is ready for merging. + If it is not ready a MergeErrorResponse is returned with + http_error_code=422. The default error code of 500 is not really + sensible because it is not an internal server error if the + attachment cannot be merged. The code 422 is used in WEB-DAV + with the meaning "Unprocessable Entity" which fits relatively + well. + """ log.debug("Checking a PDF document's readiness for merging") ffile = request.files['file'] @@ -261,13 +269,13 @@ merger.append(ffile, import_bookmarks=False) except Exception, e: log.exception("Error testing merger.append of %s" % ffile) - return MergeErrorResponse(details=str(e)) + return MergeErrorResponse(details=str(e), http_error_code=422) try: merger.write(outfile) except Exception, e: log.exception("Error testing merger.write of merged %s" % ffile) - return MergeErrorResponse(details=str(e)) + return MergeErrorResponse(details=str(e), http_error_code=422) merger.close()