From: Jan Szejko Date: Tue, 27 Dec 2016 11:12:33 +0000 (+0100) Subject: error reporting X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/194720827e4a634d5ee45001e9a091e3162a7698?ds=inline;hp=c2a6a31c6e1f6dafa17ab8e5bbd5714800ae36a3 error reporting --- diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index e3d98d8c..c43a46f5 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -175,9 +175,13 @@ def book_html(request, pk, rev_pk=None, preview=False): was_published = revision == published_revision or doc.publish_log.filter(revision=revision).exists() - sst = SST.from_string(revision.materialize()) - html = HtmlFormat(sst).build( - files_path='http://%s/media/dynamic/uploads/%s/' % (request.get_host(), pk)).get_string() + try: + sst = SST.from_string(revision.materialize()) + except ValueError as e: + html = e + else: + html = HtmlFormat(sst).build( + files_path='http://%s/media/dynamic/uploads/%s/' % (request.get_host(), pk)).get_string() # response = http.HttpResponse(html, content_type='text/html', mimetype='text/html') # return response @@ -218,7 +222,11 @@ def book_pdf(request, pk, rev_pk): ) if doc.owner_organization is not None and doc.owner_organization.logo: ctx.cover_logo = 'http://%s%s' % (request.get_host(), doc.owner_organization.logo.url) - pdf_file = PdfFormat(sst).build(ctx) + try: + pdf_file = PdfFormat(sst).build(ctx) + except BuildError as e: + from django.http import HttpResponse + return HttpResponse(content=force_str(e.message), content_type='text/plain', status='400') from catalogue.ebook_utils import serve_file return serve_file(pdf_file.get_filename(), '%d.pdf' % doc.pk, 'application/pdf') diff --git a/lib/librarian b/lib/librarian index 5135e076..1428a9d8 160000 --- a/lib/librarian +++ b/lib/librarian @@ -1 +1 @@ -Subproject commit 5135e076096ce04b1dbbb2f6210512d1a44fa237 +Subproject commit 1428a9d8f91b754fe7f9fb96cbdd0d6a2536ffc1