improve bad epub error handling
parent
31512d36b0
commit
499378ccf7
|
@ -135,6 +135,7 @@ from regluit.payment.parameters import (
|
|||
|
||||
from regluit.utils.localdatetime import now, date_today
|
||||
from regluit.booxtream.exceptions import BooXtreamError
|
||||
from regluit.pyepub import InvalidEpub
|
||||
from regluit.libraryauth.views import Authenticator
|
||||
from regluit.libraryauth.models import Library
|
||||
|
||||
|
@ -436,7 +437,7 @@ def edition_uploads(request, edition_id):
|
|||
try:
|
||||
test_acq.get_watermarked()
|
||||
context['watermarked']= test_acq.watermarked
|
||||
except (BooXtreamError, ET.ParseError) as e:
|
||||
except (BooXtreamError, ET.ParseError, InvalidEpub) as e:
|
||||
context['upload_error']= e
|
||||
form.instance.delete()
|
||||
|
||||
|
|
|
@ -137,8 +137,7 @@ class EPUB(zipfile.ZipFile):
|
|||
self.id = self.opf.find('.//{0}identifier[@id="{1}"]'.format(NAMESPACE["dc"],
|
||||
self.opf.get("unique-identifier"))).text
|
||||
except AttributeError:
|
||||
raise InvalidEpub # Cannot process an EPUB without unique-identifier
|
||||
# attribute of the package element
|
||||
raise InvalidEpub("Cannot process an EPUB without unique-identifier attribute of the package element")
|
||||
# Get and parse the TOC
|
||||
toc_id = self.opf[2].get("toc")
|
||||
expr = ".//{0}item[@id='{1:s}']".format(NAMESPACE["opf"], toc_id)
|
||||
|
|
Loading…
Reference in New Issue